-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
So web developers are used to localStorage. But we should be using Windows.Storage.ApplicationData. But of course that's an overwrought mess. WinningJS to the rescue!
Idea:
// Only localStorage examples shown, but the beauty is the same API in both cases.
var localStorage = require("WinningJS").storage.local;
var roamingStorage = require("WinningJS").storage.roaming;
// Idea #1: match ES6 map/dict methods
// Note: less powerful than ES6 map because you can't key by object
localStorage.get("setting");
localStorage.has("setting");
localStorage.set("setting", arbitraryJsonableObject);
localStorage.delete("setting");
localStorage.empty(); // not a member of ES6 map or dict. async.
// Idea #2: match window.localStorage methods
// Note: less powerful than localStorage because you can't use indexer syntax.
localStorage.getItem("setting");
localStorage.setItem("setting", arbitraryJsonableObject); // note: more powerful than window.localStorage
localStorage.removeItem("setting");
localStorage.clear(); // async, unlike window.localStorage
// window.localStorage has no `has` method.
// http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.datachanged.aspx
roamingStorage.on("sync", function (ev) { });Big missing piece: versioning!! Maybe instead of require("WinningJS").storage.local it should be require("WinningJS").storage.local.getVersion(1, upgradeHandler)?
Metadata
Metadata
Assignees
Labels
No labels