mkuklis/depot.js

Supporting sessionStorage / in-memory

simonsmith opened this issue · 2 comments

For a project I'm working on I've required depot to use sessionStorage.

I have a fork allowing the user to pass in what storage adaptor they'd prefer, be it sessionStorage, localStorage (default) or a simple object that stores the items in memory.

Is this something you'd be interested in seeing in depot? If so, I can put together a pull request for review.

Thanks

@simonsmith sounds like a great idea. depot takes a second parameter options which I think we could use to pass in the storage [sessionStorage, localStorage, object]. I think sessionStorage and localStorage share the same api but there will be more work to support object. Another approach here could be to add support for adapters in a similar fashion to lawnchair but I think it would involve even more work. I will wait for your pull request.

Yeah, the lawnchair route does seem a lot more fully-fledged. In my example I'm simply matching the local/sessionStorage API when using a custom object that keeps items in a store property. I'll push my changes later and get your thoughts.