summaryrefslogtreecommitdiff
path: root/frontend/src/store.ts
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2019-05-05 12:54:54 +0200
committerjbion <joffrey.bion@amadeus.com>2019-05-06 18:33:14 +0200
commit7499f84cdd25a8355a6c4b952c33720dfd4cb6c1 (patch)
treed2b3de98cc26b5db826a18923daf82acb764f99c /frontend/src/store.ts
parentSimplify store.js using react-devtools-extensions package (diff)
downloadseven-wonders-7499f84cdd25a8355a6c4b952c33720dfd4cb6c1.tar.gz
seven-wonders-7499f84cdd25a8355a6c4b952c33720dfd4cb6c1.tar.bz2
seven-wonders-7499f84cdd25a8355a6c4b952c33720dfd4cb6c1.zip
Convert store.js to TypeScript
Diffstat (limited to 'frontend/src/store.ts')
-rw-r--r--frontend/src/store.ts27
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,
+ };
+}
bgstack15