1.0.0 • Published 8 years ago

redux-create-reducer-curry v1.0.0

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

redux-create-reucer-curry

Build Status

create fast, save, readability reducer with fp curry

install

npm i -S redux-create-reducer-curry

API

createReducer(initState: any)(actions: obj)

  • initState
    • default: {}
    • reducer init state
  • actions
    • default: {}
    • a plain obj with function for action
      • key is action type, val is action to change reducer
      • function: (state, action) => {}
        • state: the reducer state
        • action: the action
  • @return reducer function
    • reducer for redux

usage

import createReducer

// reducer
export default createReducer({isDemo: true})({
  TOGGLE: (state, action) => ({isDemo: !state.isDemo})
})

// action
function toggle(){
  return {
    type: 'TOGGLE'
  }
}