Skip to content

A redux reducer for standard action that merge data to state

License

Notifications You must be signed in to change notification settings

magicdawn/redux-standard-reducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6e50460 · Sep 6, 2017

History

17 Commits
Sep 6, 2017
Sep 6, 2017
Aug 20, 2017
Aug 20, 2017
Aug 20, 2017
Aug 20, 2017
Sep 6, 2017
Aug 20, 2017
Sep 6, 2017
Sep 6, 2017

Repository files navigation

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

About

A redux reducer for standard action that merge data to state

Resources

License

Stars

Watchers

Forks

Packages

No packages published