on resume, WinJS.Application.sessionState does not restore object accessors RRS feed

  • Question

  • the application has passed around a date object in the winjs.navigation.navigate(page, options) call in options.


    options.startDate = new Date();

    this get stored in the navigation.history object.

    resume restore the navigation history object from the sessionobject.

    after resume - nav.state.startDate does not have the accessor methods in the date object like getFullYear, getMonth. in other words, date object is not restored only the date string is restored.



    1) is this expected behavior?

    2) if yes - is passing only primitive types recommended in the navigate call options parameter since they are not restored in case of suspension and resume for the app?








    Wednesday, December 19, 2012 7:26 AM


  • For that kind of behavior I believe its better to store the date object on the sessionState, you can hook up the logic on the checkpoint handler on the "default.js".

    app.oncheckpoint = function (args) {
            app.sessionState.startDate = nav.state.startDate; //or whatever the object is that has the value

    Then, on the resume of the App you restore the value from the sessionState
    app.onactivated = function (args) {
     args.setPromise(WinJS.UI.processAll().then(function () {
        if (app.sessionState.startDate) {
           nav.state.startDate = app.sessionState.startDate; 

    • Marked as answer by Song Tian Tuesday, December 25, 2012 8:43 AM
    Wednesday, December 19, 2012 12:57 PM