1.0.1 • Published 8 years ago

create-immutable-reducer v1.0.1

Weekly downloads
2
License
WTFPL
Repository
github
Last release
8 years ago

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);