diff options
author | Indrajith K L | 2019-12-11 18:54:05 +0530 |
---|---|---|
committer | Indrajith K L | 2019-12-11 18:54:05 +0530 |
commit | 8988233da897e8447a1dbdb700836fb8576e5e6b (patch) | |
tree | 0bcaaf9657f35320ea110085ed0c40f815100a55 /src/core/store.js | |
parent | 53e5edb3d93d957f82034be43940d560540525a8 (diff) | |
download | react-redux-saga-starter-8988233da897e8447a1dbdb700836fb8576e5e6b.tar.gz react-redux-saga-starter-8988233da897e8447a1dbdb700836fb8576e5e6b.tar.bz2 react-redux-saga-starter-8988233da897e8447a1dbdb700836fb8576e5e6b.zip |
:tada: Initial Commit
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; +} |