mobx-sync-storage
Sync persist storage between Local/Session Storage and MobX
Features
- Available both LocalStorage and SessionStorage
- Performant
- Easy
Note
- Available only for ES6 & Class supported browsers
Installation
We recommend install via npm
because of it's cache and flat node modules tree
npm i mobx-sync-storage
then you able to import to Node.js/Browser easily
// only ES6 or Browser ES6 Module loading works; // or CJSconst SyncStore = ;
Usage
;store.myKey = "or no??";
and then load created file. Should work as works for me too!
Lifecycles
- onSessionRestore(session?: DeserializedSession)
- onSessionSaved(merged?: MergedSession, store?: StoreProperties, session?: DeserializedSession)
- onSessionUnchanged(store?: StoreProperties)
Methods
- deserialize
- serialize
Caveats
null
not work or converting not working properly- Only Primitive values works properly
- When you changing something in current tab, things will change into
current tab
, all others tab keep their state, forlocalStorage
, things will change only you visit to that tab - When you using
localStorage
on 2+ tabs, latest changes may bypass previous change by force-pushing changes and you may lose prev-last state
License
MIT