redux-createreducer
v2.0.0
Published
Creates a reducer from an object with action handlers
Downloads
82
Readme
create-reducer
Creates a Redux reducer from an ActionHandlers object
CreateReducer :: State a, ActionHandlers b, Action c => a,b -> (a,c -> a)
ActionHandlers :: ActionType a, State b, Action c => {a: (b,c -> b), ...}
Creates a reducer from an object that each property name is an actionType and its value is a function that receive a state and an action and return a new state
How to install
$ npm install redux-createreducer --save
Example:
import createReducer from 'redux-createreducer';
const initialState = 0;
const actionHandlers = {
'INCREMENT': (state, action) => state + 1,
'DECREMENT': (state, action) => state - 1
};
const reducer = createReducer(initialState, actionHandlers);