rubys

1.0.6 • Public • Published

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

/rubys/

    Package Sidebar

    Install

    npm i rubys

    Weekly Downloads

    1

    Version

    1.0.6

    License

    ISC

    Unpacked Size

    2.63 kB

    Total Files

    3

    Last publish

    Collaborators

    • bobtxt