reistore - Relational Immutable State Manager
Make state managers greate again!
- Faster initialization compare to redux
- Native SSR support
- Transactions
- You need "Reducer" only when need to describe store relationships
- Comparable speed with redux
- Supports module architecture
Install
npm i reistore
Examples
Usage
Simple
; const initState = counter: 0;const store = ;const counter = Path; store; store;// > Counter value: 1const value = storestatecounter;// value = 1
Batch API
You also can use batch api for executing series of commands. Batch always faster when you need execute more than one command.
; const initState = counter: 0;const store = ;const counter = Path; store; console; // same as store.state.counter// value = 3
Injection API
You also can use injection API that give you access to state in batch and access to store modification.
; const initState = counter: 0;const store = ;const counter = Path; store; console;// value = 5
Min-Max transform
; const initState = min: 0 max: 0;const path = min: Path max: Path { change; // apply change to state if statemin > statemax ; // apply change to max if min > max else if statemax < statemin ; // apply change to max if max < min }const store = ; store;console;// { min: 1, max: 1 } store;console;// { min: -9, max: -9 } store;// { min: -15, max: -9 }console;
Scope
; const initState = sum: 0;const scopeInitState = min: 0 max: 0const schema = ; { if change && changevalue > scopemax // if changed min and new value(min) > state.scope.max ; else if change && changevalue < scopemin // if changed max and new value(max) < state.scope.min ; change; // apply change to state ; // update sum}const scope = ;const path = sum: Path min: scope max: scopeconst store = ; store;console;// { min: 1, max: 1 }console;// { sum: 2, scope: { min: 1, max: 1 } }