Organize store for redux with redux-saga.
-
import makeStoreConfigurer from 'dreact/helper-store' export default makeStoreConfigurer(params) export default makeStoreConfigurer({ initialState: {}, sagas: [require('./custom-saga.js').default], reducers: { form: require('redux-form').reducer, }, reducerMiddleware: appReducer => (state, action) => { if (action.type === logoutAction.SUCCESS) { return appReducer(undefined, action) } return appReducer(state, action) }, })
-
Initial state of the entire store
-
Contains references to necessary sagas which will be combined then
sagas: [require('src/lib/custom-saga.js').default]
In addition to that the list will be extended with sagas defined inside collections. It's done by babel.
-
Contains references to necessary reducers which will be combined then
reducers: { form: require('redux-form').reducer, }
In addition to that the object will be extended with reducers defined inside collections. It's done by babel. Reducers specified manually will override automatically added.
-
In case you'd like to handle actions and changes in reducer you can do that here by creating a middleware on top of main reducer.
reducerMiddleware: appReducer => (state, action) => { // Define custom behavior for actions with type 'LOGOUT' if (action.type === 'LOGOUT') { return appReducer(undefined, action) } // Proceed with default behavior: return appReducer(state, action) }
-
-
It's an alias of used
redux-saga/effects
inside. -
It's an action that can be dispatched in store. It's been designed to restart sagas (stop everything and run again).
import { RESTART, effects } from 'dreact/helper-store' function* someSaga() { yield effects.put(RESTART) }