From 8988233da897e8447a1dbdb700836fb8576e5e6b Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 11 Dec 2019 18:54:05 +0530 Subject: :tada: Initial Commit --- src/core/store.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/core/store.js (limited to 'src/core/store.js') 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; +} -- cgit v1.2.3