diff options
Diffstat (limited to 'frontend/src/store.ts')
-rw-r--r-- | frontend/src/store.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/frontend/src/store.ts b/frontend/src/store.ts new file mode 100644 index 00000000..54a65509 --- /dev/null +++ b/frontend/src/store.ts @@ -0,0 +1,27 @@ +import createHistory from 'history/createBrowserHistory'; +import { routerMiddleware } from 'react-router-redux'; +import { applyMiddleware, createStore } from 'redux'; +import { composeWithDevTools } from 'redux-devtools-extension'; +import createSagaMiddleware from 'redux-saga'; +import { GlobalState } from './reducers'; +import { createReducer } from './reducers'; +import { rootSaga } from './sagas'; + +export function configureStore(initialState: GlobalState) { + const sagaMiddleware = createSagaMiddleware(); + + const history = createHistory(); + + const middlewares = [sagaMiddleware, routerMiddleware(history)]; + + const enhancers = [applyMiddleware(...middlewares)]; + + const store = createStore(createReducer(), initialState, composeWithDevTools(...enhancers)); + + sagaMiddleware.run(rootSaga); + + return { + store, + history, + }; +} |