localstorage-lib
v1.0.8
Published
`const store = new StoreManager(localStorage, 'prefix_')`
Downloads
2
Readme
const store = new StoreManager(localStorage, 'prefix_')
store.set('age', 23)
store.set({user: {age: 23, male: true})
store.get(user) ===> Object<{user: {age: 23, male: true}}>
store.update('age', (old) => old + 1) ===> store.get('age') === 24
store.subscribe({key, prefix, callback})
store.findByPattern(/^prefix_.+$/)
You can subscribe to storage update event:
- You can specify exact key of storage. So if value of this key are updated callback will triggered
- You may cannot specify key. So, callback are triggered everytime when some data in storage was update.
- You can specify the prefix. So, callback are triggered only if your data which added by store manager will update.
- You can get array of objects by regex.