JSPM

@guiguzixl/redux-add-reducer

2.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 156
  • Score
    100M100P100Q53150F
  • License ISC

Redux enhancer which adds dynamically reducer

Package Exports

  • @guiguzixl/redux-add-reducer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@guiguzixl/redux-add-reducer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

redux-add-reducer

Add dynamically reducer.

install

npm install --save @guiguzixl/redux-add-reducer

or

yarn add @guiguzixl/redux-add-reducer

example

用法和 redux 几乎一样,区别在于创建 store 的时候不用再传入 reducer,而是通过 store.addReducer 动态的添加 reducer。addReducer 接受一个对象为参数,和 combineReducers 一致,另外 preloadedState 必须为对象。

import { createStore } from '@guiguzixl/redux-add-reducer'
const store = createStore(preloadedState, enhancer)

const addReducerShape = {
  reducerKey: reducerFunction,
}
store.addReducer(addReducerShape)