A redux reducer for standard action that merge data to state
$ npm i redux-standard-reducer --save
// suppose all business reducer exits in app/reducers/
import reducer from './app/reducers'
import standardReducer from 'redux-standard-reducer'
import reduceReducers from 'reduce-reducers'
// reducer for createStore
const finalReducer = reduceReducers(
standardReducer,
reducer
)
const store = createStore(initialState, finalReducer, enhancers)
use any one of these:
- make
action.type
starts withSTANDARD_MERGE_STATE
, this reducer will handle the action - make
action.standard = true
, this reducer will handle the action
action = {
type,
standard,
payload: {...},
}
key | type | remark |
---|---|---|
payload |
Object |
the data need to be merged to the store.state |
- more see the test/simple.js
action = {
type,
standard,
update: {...},
}
key | type | remark |
---|---|---|
update |
Object |
the update operation, will pass to immutability-helper, equal to immutabilityHelper(store.state, action.update) |
- more see the test/simple.js
- see
update
in immutability-helper homepage
the MIT License http://magicdawn.mit-license.org