locked
Storing app data in Roaming folder then and there. Is it okay.

    Question

  • I am having my shopping list app data in roaming folder. When the app is launched, I load from the files in my roaming folder. Then when the app is suspended I load all the data(edited)  to those files. Whenever something is added/deleted/changed I save it immdly to the file in the roaming folder as well (Just to have as much data saved, in case of a power off or something).
     
     I do this because 1)my app can have data only less than 100KB size, the roaming storage quota now.  2)I see there is a local folder called Roamingstate to be used to sync with roaming storage.  So it will act as a local copy right?
    (But I am not expecting immediate sync)
    Is there anything that needs to be changed? Is a copy in the local folder (Localstate) needed?

    karthika

    Monday, May 13, 2013 9:58 PM

Answers

  • Correct. Roaming state acts just like local, and as long as you stay under the 100K limit, the cloud sync happens. If you go over 100K, then roaming isexactly like local. :)

    Note that even though you're potentially doing a bunch of reads/writes to the roaming folder, those changes are combined automatically so you're not triggering a bunch of network traffic.

    • Marked as answer by ArunKarthika Wednesday, May 15, 2013 2:56 AM
    Monday, May 13, 2013 10:59 PM
  • The datachanged event will be fired when a cloud > appdata sync has happened (e.g. it just finished). This has nothing to do with activation and can occur at any time. You also don’t see this event when you write to the roamingfolder yourself. That is, the event tells you that changes from the app running on another device has been sync’d in your app data, so you need to load and reconcile those changes.

    If you want to tell yourself that you’ve changed the data, e.g. to centralize handling of such changes, you can use the signalDataChanged method on the ApplicationData object.

    As for errors in promises, here’s how it works:

    • If you have an error handler attached to any given .then call, that one will catch any errors that occur on that level or earlier in a chain.
    • If you don’t have an error handler at any particular .then call in a chain, the error gets propagated to the next step in the chain.
    • If you end a chain with .then and don’t have any error handlers, the error is swallowed (this is the silent behavior you’re seeing).
    • If you end a chain with .done instead (as recommended), you can catch errors in a handler attached to .done.
    • If an error hits .done and you don’t have an error handler, it gets thrown to the app level.
    • At the app level, you can catch errors in a window.onerror or WinJS.Application.onerror handler. This is how you can do a global catch-all handler instead of dealing with them locally.
    • Lacking an app-level handler, exceptions thrown out of a promise chain via .done will terminate the app.
    • Marked as answer by ArunKarthika Wednesday, May 15, 2013 2:56 AM
    Tuesday, May 14, 2013 8:24 PM

All replies

  • Correct. Roaming state acts just like local, and as long as you stay under the 100K limit, the cloud sync happens. If you go over 100K, then roaming isexactly like local. :)

    Note that even though you're potentially doing a bunch of reads/writes to the roaming folder, those changes are combined automatically so you're not triggering a bunch of network traffic.

    • Marked as answer by ArunKarthika Wednesday, May 15, 2013 2:56 AM
    Monday, May 13, 2013 10:59 PM
  • Thanks again Kraig. In this case should I handle data change handler? Will data change handler download data from the cloud instead of local roamingstate folder? Will it get invoked whenever data changes or only if there is a changed data while activation.

    One other thing pls,   What will happen if I don't handle then( file open/read/write promise)'s error. I saw the unhandled exceptions are silently captured as part of the state of the promise.  Means the page will still load even if the full data is not recovered from the files?. Can I handle the onerror and display a messagebox?

    Thanks so much.


    karthika

    Monday, May 13, 2013 11:43 PM
  • The datachanged event will be fired when a cloud > appdata sync has happened (e.g. it just finished). This has nothing to do with activation and can occur at any time. You also don’t see this event when you write to the roamingfolder yourself. That is, the event tells you that changes from the app running on another device has been sync’d in your app data, so you need to load and reconcile those changes.

    If you want to tell yourself that you’ve changed the data, e.g. to centralize handling of such changes, you can use the signalDataChanged method on the ApplicationData object.

    As for errors in promises, here’s how it works:

    • If you have an error handler attached to any given .then call, that one will catch any errors that occur on that level or earlier in a chain.
    • If you don’t have an error handler at any particular .then call in a chain, the error gets propagated to the next step in the chain.
    • If you end a chain with .then and don’t have any error handlers, the error is swallowed (this is the silent behavior you’re seeing).
    • If you end a chain with .done instead (as recommended), you can catch errors in a handler attached to .done.
    • If an error hits .done and you don’t have an error handler, it gets thrown to the app level.
    • At the app level, you can catch errors in a window.onerror or WinJS.Application.onerror handler. This is how you can do a global catch-all handler instead of dealing with them locally.
    • Lacking an app-level handler, exceptions thrown out of a promise chain via .done will terminate the app.
    • Marked as answer by ArunKarthika Wednesday, May 15, 2013 2:56 AM
    Tuesday, May 14, 2013 8:24 PM