blob: 9c0be13acc95510b4c2b6ac430aa595b315288c2 (
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
32
33
|
// @flow
import createHistory from 'history/createBrowserHistory';
import { fromJS } from 'immutable';
import { routerMiddleware } from 'react-router-redux';
import { applyMiddleware, compose, createStore } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { createReducer } from './reducers';
import { rootSaga } from './sagas';
export function configureStore(initialState: Object = {}) {
const sagaMiddleware = createSagaMiddleware();
const history = createHistory();
const middlewares = [sagaMiddleware, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
const composeEnhancers = process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: compose;
const store = createStore(createReducer(), fromJS(initialState), composeEnhancers(...enhancers));
sagaMiddleware.run(rootSaga, history);
return {
store,
history,
};
}
|