reducer-generator-reducer
v1.1.0
Published
A redux reducer-generator which builds a redux-reducer from a redux-reducer.
Downloads
7
Maintainers
Readme
reducer-generator-reducer
A reducer-generator
which builds a reducer that reduces a reducer. In most
cases this is not useful. It is, however, useful for libraries that are building
reducers from various object types as it allows us to inject arguments into the
reduction chain.
Installation
yarn add reducer-generator-reducer
or
npm install --save reducer-generator-reducer
Simple Example
import createReducerReducer from 'reducer-generator-reducer'
const system = createReducerReducer(
{ /* initial state */ },
(state, action) => {
switch(action.type) {
case 'SYSTEM_ONLINE': {
return {
...state,
isOnline: true
}
}
case 'SYSTEM_OFFLINE': {
return {
...state,
isOnline: false
}
}
}
return state
},
/* You may pass extra args that will be passed to the reducer(s) */
)