redux-magic-reducer
v1.0.0
Published
This library aims at solving the problem dynamic reducer problem (please read: https://stackoverflow.com/questions/32968016/how-to-dynamically-load-reducers-for-code-splitting-in-a-redux-application). This implementation is based on answer provided by @[g
Downloads
3
Readme
redux-magic-reducer
This library aims at solving the problem dynamic reducer problem (please read: https://stackoverflow.com/questions/32968016/how-to-dynamically-load-reducers-for-code-splitting-in-a-redux-application). This implementation is based on answer provided by @gaearon .
Why?
To make redux applications simpler by allowing dynamic state creation, specifically in cases where code splitting is done.
Install
npm install --save redux-magic-reducer
How to use
1. Create a Store
import { createStore } from 'redux-magic-reducer';
const globalReducer = {
app: () => {
return {
appName: 'redux-magic-reducer'
};
}
};
let store = createStore(reducers);
2. Attach a dynamic Reducer
const dynamicReducer = (state = { subReducerKey: "subReducerValue" }, action) {
switch(action.type) {
default:
return state;
}
};
store.attachReducer('this.is.your.dynamic.path', dynamicReducer);
License
MIT © saurabhnemade