0.1.0 • Published 7 years ago

redux-standard-reducer v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

redux-standard-reducer

A redux reducer for standard action that merge data to state

Build Status Coverage Status npm version npm downloads npm license

Install

$ npm i redux-standard-reducer --save

Usage

// suppose all business reducer exits in app/reducers/
import reducer from './app/reducers'

import standardReducer from 'redux-standard-reducer'
import reduceReducers from 'reduce-reducers'

// reducer for createStore
const finalReducer = reduceReducers(
  standardReducer,
  reducer
)

const store = createStore(initialState, finalReducer, enhancers)

enable this reducer

use any one of these:

  • make action.type starts with STANDARD_MERGE_STATE, this reducer will handle the action
  • make action.standard = true, this reducer will handle the action

Action with payload

action = {
  type,
  standard,
  payload: {...},
}
keytyperemark
payloadObjectthe data need to be merged to the store.state

Action with update

action = {
  type,
  standard,
  update: {...},
}
keytyperemark
updateObjectthe update operation, will pass to immutability-helper, equal to immutabilityHelper(store.state, action.update)

Changelog

CHANGELOG.md

License

the MIT License http://magicdawn.mit-license.org