redux-standard-reducer

0.1.0 • Public • Published

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: {...},
}
key type remark
payload Object the data need to be merged to the store.state

Action with update

action = {
  type,
  standard,
  update: {...},
}
key type remark
update Object the 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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    0
  • 0.0.3
    1
  • 0.0.2
    1
  • 0.0.1
    0

Package Sidebar

Install

npm i redux-standard-reducer

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • magicdawn