@higherorder/shinju
v0.1.5
Published
Helps in maintaining and manipulating your application State
Downloads
10
Readme
Shinju
Helps in maintaining and manipulating your application State
Examples
import Shinju from '@higherorder/shinju';
const MutableTree = Shinju();
MutableTree.add(35, 'rollNo');
console.log(MutableTree.getTree().get('rollNo')); //=> 35;
import Shinju from '@higherorder/shinju';
const ImmutableTree = Shinju();
const NewTree = ImmutableTree.addChain(35, 'rollNo').addChain(
500023356,
'sapId',
);
console.log(NewTree.getTree()); //=> { sapId: 500023356, rollNo: 35 }
console.log(ImmutableTree.getTree()); //=> {}
Available Functions
add
import Shinju from '@higherorder/shinju';
const StateTree = Shinju();
StateTree.add(35, 'rollno');
get
StateTree.get('rollno'); //=> 35
getTree
StateTree.getTree(); //=> { rollno: 35 }
subscribe
StateTree.subscribe(_ => console.log(StateTree.getTree()));
StateTree.add('Rajat Sharma', 'name');
//=> { rollNo: 35, name:'Rajat Sharma' }
addChain
const NewStateTree = StateTree.addChain(500023356, 'sapId')
.addChain('CSEOG', 'branch')
.getTree(''); //=> { rollno: 35, sapId: '50023356', branch: 'CSEOG' }