2018-08-23 16:29:26 +01:00
|
|
|
import { createStore as reduxCreateStore, applyMiddleware } from 'redux';
|
|
|
|
import createSagaMiddleware from 'redux-saga';
|
|
|
|
|
|
|
|
import rootReducer from './rootReducer';
|
|
|
|
import rootSaga from './rootSaga';
|
|
|
|
|
|
|
|
const sagaMiddleware = createSagaMiddleware();
|
|
|
|
|
|
|
|
export const createStore = () => {
|
2018-09-07 11:06:00 +01:00
|
|
|
const store = reduxCreateStore(rootReducer, applyMiddleware(sagaMiddleware));
|
2018-08-23 16:29:26 +01:00
|
|
|
sagaMiddleware.run(rootSaga);
|
2018-09-13 18:29:19 +01:00
|
|
|
if (module.hot) {
|
|
|
|
// Enable Webpack hot module replacement for reducers
|
|
|
|
module.hot.accept('./rootReducer', () => {
|
|
|
|
const nextRootReducer = require('./rootReducer');
|
|
|
|
store.replaceReducer(nextRootReducer);
|
|
|
|
});
|
|
|
|
}
|
2018-08-23 16:29:26 +01:00
|
|
|
return store;
|
|
|
|
};
|