@werkin/store
v0.0.18
Published
Simple runtime storage with possibility to watch changes
Downloads
54
Keywords
Readme
Werkin-store
Runtime storage with possibility to watch changes
Installation
npm i @werkin/store
yarn add @werkin/store
API
.set(string, any type)
Possible to set deep property separate key by dots key.deepKey
.
store.set('key.deepKey', 'any value');
store.get('key'); // { deepKey: 'any value'}
.get(string)
For get value by key immediately
.unset(string)
For deleting some item from store
.subscribe(string, callback function)
Callback will be called when value or inner property has updated
.clear()
Force clearing store with removing all subscribers
.snapshot
Lets to get full store object immediately
Example usage
import store from '@werkin/store';
store.set('new_key', 'new value');
store.get('new_key'); // 'new value';
store.unset('new_key');
store.subscribe('new_key', (newValue) => {
//Can use new value here
});
store.clear();
store.snapshot;