the-store
Redux wrapper for the-framework
- Simple wrapper of redux
- Class base state management
- Pseudo scoped state
- Auto action-type generate
- Load redux-devtools automatically
Installation
$ npm install the-store --save
Why This?
- Reusing reducer logic with Class.
- No need to care about ActionTypes.
- Access to state with scope.
- Full compatible with original redux
Usage
'use strict' const theStore = const Scope = theStore // Scoped state class // Define initial state static { return 0 } // Define reducer factory static { return { return state + amount } } { let store = // Create state instance and attach to the store store store // Access to loaded store let counterA = store // Each instance has dispatcher methods which share signatures with reducerFactories // Invoking this method dispatches an action and reduce it into state // The action looks like { type: "counterA/increment", payload: [1] } counterA // Access to the scoped state console // -> 1 // Store it self has all state console // -> { counterA: 1 }}
Usage
Nested Scopes
'use strict' const theStore = defaultconst ObjectScope BooleanScope = theStore { const store = // Create nested scope store store const scopeA = store scopeA scopeAenabled console // -> true console // -> { foo: 'bar' } console // -> { scopeA: { foo: 'bar'} , 'scopeA.enabled': true } }}
API Guide
License
This software is released under the MIT License.