redux-dynamic-registry
v0.4.2-beta
Published
A dynamic reducer, middleware, and observer registry for Redux
Downloads
10
Readme
Redux Dynamic Registry
Redux Dynamic Registry is a tool to dynamically add and remove reducers and middleware. It was conceived to aid code-splitting.
It's very small, weighing-in <600B minified and gzipped.
Usage
import { createStore } from 'redux';
import { createDynamicMiddleware, createDynamicReducer } from 'redux-dynamic-registry';
// Middleware
const dynamicMiddleware = createDynamicMiddleware();
const store = createStore(
reducer,
applyMiddleware(
// ...other app middleware,
dynamicMiddleware.middleware
)
);
dynamicMiddleware.add(middleware, order);
dynamicMiddleware.remove(middleware);
// Reducer
const dynamicReducer = createDynamicReducer();
dynamicReducer.add(store, namespace, reducer);
dynamicReducer.remove(store, namespace);