3 ms·
HTML5-ish window.remoteStorage with openkeyval.js
Howdy, Hackers;
Last week, dustball and I announced OpenKeyval.org here (http://news.ycombinator.com/item?id=1846088), and we got some great feedback. One thing we heard from a few people was a desire for it to be easier to work with from JavaScript. That was something I was very happy to hear, since this idea came out of my own brainstorming around making server-less web apps that could still have non-local state.
With that in mind, I'd like to introduce openkeyval.js, which offers an interface to OpenKeyval.org that's vaguely modeled after HTML5's local storage.
// Here's how you set a value
window.remoteStorage.setItem('location', 'the couch', optionalCallbackFunction);
// Here's how you retrieve a value
window.remoteStorage.getItem('location', function(value, key) {
alert('The value of ' + key ' + is ' + value);
});
Take a look at the site for more details and a link to the code. We're hosting a minified version on a CDN (incidentally, http://maxcdn.com is pretty awesome), so you can feel free to link directly to it from your sites with a reasonable expectation of reliability and speed.
As always, thanks for reading and please let us know what you think.
PS: This is definitely a first revision. Although it has memoization, it doesn't have any provision for local caching, and it can only get/set one item at a time -- basically, there is definitely a lot of room for performance improvements.
- markchristian 16y agoClickable link: http://openkeyval.org http://openkeyval.org