case-reducer

1.0.15 • Public • Published

case-reducer

!Deprecated: Use reducer-interface instead.

Installation

$ npm install case-reducer --save

Usage

import caseReducer from "case-reducer"
import {
  REQUEST_USER,
  USER_RESPONSE
} from "actions/user"
 
const initialState = {
  isFetching: false,
  id: null,
  username: null
}
 
const cases = {
  [ REQUEST_USER ] (state) {
    return {
      ...state,
      isFetching: true
    }
  },
 
  [ USER_RESPONSE ] (state, data) {
    const { user } = data
 
    return {
      ...state,
      isFetching: false,
      ...user
    }
  }
}
 
export default caseReducer(initialState, cases)

See also

Travi$ Scott - Don't Play ft. Big Sean, The 1975

Package Sidebar

Install

npm i case-reducer

Weekly Downloads

2

Version

1.0.15

License

MIT

Last publish

Collaborators

  • ideal-life