create-immutable-reducer
v1.0.1
Published
Create reducer from object of action handlers for use with redux and immutable for state.
Downloads
6
Maintainers
Readme
create-immutable-reducer
Create a redux reducer from an object of action handling functions, keyed by the actions they handle. Has validates for Immutable state.
const createReducer = require('create-immutable-reducer');
const { fromJS } = require('immutable');
const initialState = fromJS({
first: 1,
second: 2,
});
module.exports = createReducer({
ACTION_TYPE_CHANGE_FIRST(state, action) {
return state.set('first', action.first);
},
ACTION_TYPE_CHANGE_SECOND(state, { second }) {
return state.set('second', second);
},
}, initialState);