Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide storage abstractions #1

Open
domenic opened this issue Jun 5, 2012 · 0 comments
Open

Provide storage abstractions #1

domenic opened this issue Jun 5, 2012 · 0 comments

Comments

@domenic
Copy link
Contributor

domenic commented Jun 5, 2012

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant