aboutsummaryrefslogtreecommitdiff
path: root/src/core/store.js
blob: 5e55424078fe62c4338e2b9e44e9e6066168a6f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}