The primary goal of this npm package, is to make it easy to modularize large redux applications.
Avoid large central imports.
Decouple independent features.
Only load logic if the component was rendered.
Allow for lazy loading of components.
npm install --save enhance-store
Initializes the store and stores any provided reducers.
/* Create the store where reducers is an object */
const store = createStore(combineReducers(reducers));
/* initialize it in enhance-store */
initializeStore(store, reducers);
export default store;
Enhance store provides the store with the new components reducer.
Under the hood, it operates by calling replaceStore
on the redux-store.
import exampleReducer from './exampleReducer';
class ExampleComponent extends React.Component {
/* enhance the store, we are doing it in the body since
componentWillMount is now being depreceated */
enhanceStore('example', exampleReducer);
/* ... */
}
enhance-store
provides the following lifcycle hooks to use how you like:
@ENHANCE_STORE/ADD_REDUCER_START
: Fires before start of adding a new reducer to the store.
@ENHANCE_STORE/ADD_REDUCER_SUCCESS
: Fires after a new reducer has been added to the store.
Removes a reducer from the store by calling: replaceStore
on the redux-store
enhance-store
provides the following lifcycle hooks to use how you like:
@ENHANCE_STORE/REMOVE_REDUCER_START
: Fires before the start of removing a reducer.
@ENHANCE_STORE/REMOVE_REDUCER_SUCCESS
: Fires after a reducer has been removed from the store.
Tests are written in Jest.
To run tests: npm run test
To run tests in watch mode: npm run test:watch