[Windows.Storage.ApplicationData.Current.localSettings] (http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.aspx) or roamingSettings provide the builtin support for getting/setting setting key-value pair. It also handles the persisting to a file in application data folder. It also does required batching as per documentation.
you can find the reference code in the application data sample
var roamingSettings = Windows.Storage.ApplicationData.current.roamingSettings;
function settingsWriteSetting() {
roamingSettings.values['my setting'] = 'my setting value';
}
regards, events on the flyout - there events can be used to take some action before/after flyout is hidden - in the overall user flow. For example - I have once created a Promise around a signin flyout. afterhide
was used to call error callback for the promise, with error as canceled.