marcuswestin / store.js

Cross-browser storage for all use cases, used across the web.
MIT License
14.01k stars 1.33k forks source link

Ability to choose storage type #276

Open amellini opened 6 years ago

amellini commented 6 years ago

I'd like to choose the default storage engine (sessionStorage, i need to store different information for different tabs), i don't use NPM. It will be a good solution to allow the user to select a "default" storage and if not available to fall to other engine.

There's a simple way to do this or i need to create my own store pack (with the list of all engines)?

yonib05 commented 5 years ago

+1

galtenberg commented 4 years ago

Now I get why the docs don't explain how to do this. Would love to! I currently import via unpkg.

🙏

dgbeck commented 4 years ago

yes, sometimes you want localStorage and sometimes you want sessionStorage, for different use cases. but you want to use the same nice API for both...

TafkaMax commented 3 years ago

If i am using NPM how do I choose storage type, I also want to use sessionStorage.

roy-rayyone commented 1 year ago

try this

import store from 'store';
// @ts-ignore
import cookieStorage from 'store/storages/cookieStorage';

const cs = store.createStore([cookieStorage]);
cs.set(key, value);