create-immutable-reducer

    1.0.1 • Public • Published

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

    Install

    npm i create-immutable-reducer

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    WTFPL

    Last publish

    Collaborators

    • lestad