Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 574 Bytes

README.md

File metadata and controls

22 lines (18 loc) · 574 Bytes

Installation

$ npm install redux-contrib --save

USAGE

  import { createAction, createReducer } from 'redux-contrib';

  const createUserAction = createAction('CREATE_USER_ACTION', ['email', 'name']);

  const initialState = { user: undefined };
  const reducer = createReducer([
    [
      createUserAction,
      (_state, payload, _action) => ({ user: { email: payload.email, name: payload.name } }),
    ],
  ], initialState)

  const action = createUserAction({ email: '[email protected]', name: 'John Doe' });
  reducer(initialState, action);