reduxreducercreator
v0.0.7
Published
ReduxReducerCreator lets you create a reducer without using the switch statement
Downloads
3
Maintainers
Readme
reduxreducercreator []
https://github.com/nirmaoz/reduxreducercreator
ReduxReducerCreator lets you create a reducer without using the switch statement. Provides a default handler for non-existing action types that returns the state. The default handler is replaceable (just provide it as the last argument).
Installation
$ npm i --save reduxreducercreator
Usage
const reducerCreator = require("./reduxreducercreator");
let newReducer = (state, action) => {
return reducerCreator(state, action, {
action_type_1: (state, action) => { //action handler for type_1
return ...
},
action_type_2: (state, action) => { //action handler for type_2
return ...
}
});
};
API
reduxreducercreator ( state, action, actionHandlers, defaultHandler=()=>return state )
Tests
License
MIT © Nir Maoz