rubys
v1.0.6
Published
Super light and simple to use global application state and storage, subscribe/unsubscribe for data change etc..
Downloads
2
Maintainers
Readme
Simple & light weight state storage
When data changes every subscribers gets notified.
Ultra-light code, ~600 bytes and 20 lines of code
Subscribing to the store
Store.bind('your-key', this.callBackWhenStateChanges);
Storing data to store
Store.set('your-key', 'your-value');
Getting data from store
Store.get('your-key');
ReactJS EXAMPLE
STORE DATA TO STORE
import Store from 'rubys';
<button onClick={()=> Store.set('user', {id:1, name:'Bobby'} ) }>Save</button>
RECEIVE DATA CHANGE FROM STORE
import Store from 'rubys';
componentDidMount =()=> {
Store.bind('user', (newUserVal, oldUserVal)=> {
//user value changed event
});
};
GET DATA CHANGE FROM STORE
import Store from 'rubys';
componentDidMount =()=> {
let userInfo = Store.get('user');
};
REMOVE BINDING
import Store from 'rubys';
componentWillUnmount() {
Store.unbind('user');
};