diff options
Diffstat (limited to 'src/core/store.js')
-rw-r--r-- | src/core/store.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/core/store.js b/src/core/store.js new file mode 100644 index 0000000..5e55424 --- /dev/null +++ b/src/core/store.js @@ -0,0 +1,31 @@ +import { createStore, applyMiddleware } from "redux"; +import { routerMiddleware } from "connected-react-router"; +import createSagaMiddleware from "redux-saga"; +import { createBrowserHistory } from "history"; +import { composeWithDevTools } from "redux-devtools-extension/developmentOnly"; + +import createRootReducer from "../reducers/root.reducer"; + +export const history = createBrowserHistory({ + hashType: "slash" +}); + +const RouterMiddleware = routerMiddleware(history); +const SagaMiddleware = createSagaMiddleware(); + +const getMiddleware = () => { + // DEVELPOPMENT + return composeWithDevTools(applyMiddleware(SagaMiddleware, RouterMiddleware)); + // PRODUCTION + // return compose(applyMiddleware(SagaMiddleware, RouterMiddleware)); +}; + +export function configureStore(initialState) { + const store = createStore( + createRootReducer(history), + initialState, + getMiddleware() + ); + store.runSaga = SagaMiddleware.run; + return store; +} |