summaryrefslogtreecommitdiff
path: root/sw-ui/src/store.ts
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2019-05-16 23:48:38 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2019-05-16 23:48:38 +0200
commit2382a452456e4bdef4584e1046925e372624cb79 (patch)
tree0e49b2e5d81facb55fb8b08228abeb218a27d466 /sw-ui/src/store.ts
parentRemove GRADLE_METADATA feature to avoid breaking frontend build (diff)
downloadseven-wonders-2382a452456e4bdef4584e1046925e372624cb79.tar.gz
seven-wonders-2382a452456e4bdef4584e1046925e372624cb79.tar.bz2
seven-wonders-2382a452456e4bdef4584e1046925e372624cb79.zip
Rationalize module names
Diffstat (limited to 'sw-ui/src/store.ts')
-rw-r--r--sw-ui/src/store.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/sw-ui/src/store.ts b/sw-ui/src/store.ts
new file mode 100644
index 00000000..54a65509
--- /dev/null
+++ b/sw-ui/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,
+ };
+}
bgstack15