1.0.6 • Published 5 years ago

rubys v1.0.6

Weekly downloads
11
License
ISC
Repository
github
Last release
5 years ago

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');		
};
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago