1.1.0 • Published 8 years ago
reducer-generator-reducer v1.1.0
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-reduceror
npm install --save reducer-generator-reducerSimple 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) */
)