store.js
store.js copied to clipboard
Support for async storage (IndexedDB, WebSQL, ...)
IndexedDB exists in many modern browsers. I don't know about performances vs. localStorage. Support for IndexedDB would be great :)
A good place to start might be looking at https://github.com/localForage/localForage and get a sense of how we'd want to do jt
@marcuswestin it seems as though it is some minor setup, environment checks to make it happen. The calls that it makes would need to be asynchronous though. I know that you are pretty focused on keeping a synchronous project, but a simple promise shim would keep functionality for < ie8
We definitely need to add an async API.
I like the idea of having a sync, localStorage backed store for more trivial key-value storage and an async indexDB backed store for larger blobs working in parallel.
I'm considering a few options:
store.get.async('foo').then(...)andstore.set.async('foo', 'bar').then(...)store.async.read('foo').then(...)orstore.blobs.read/writeetc
I'd love input on this!
@marcuswestin, I think you have the right idea for a starting point. Although, I think that the async object in the library should expose 2 items: get set as opposed to the other way around. store.async.get('foo').then(...) and store.async.set('foo', 'bar').then(...) looks cleaner to me. In terms of reading/writing blobs/files why not just have this functionality put into get/set?
There is a wrapper called Dexie. anyone comment on how is that ?