2021-05-12 06:35:00 +00:00
|
|
|
|
/// <reference types="webpack-env" />
|
2021-11-03 08:06:52 +00:00
|
|
|
|
import { applyMiddleware, compose, createStore, Store } from 'redux';
|
2016-11-07 20:24:38 +00:00
|
|
|
|
import thunkMiddleware from 'redux-thunk';
|
2021-07-22 23:04:56 +00:00
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
|
import { reducer } from './modules';
|
2016-04-29 05:58:37 +00:00
|
|
|
|
|
2021-06-14 15:18:35 +00:00
|
|
|
|
// TODO there's a circular dependency between this file and /redux/create
|
2018-06-25 17:42:50 +00:00
|
|
|
|
export default function() {
|
2017-07-20 19:09:07 +00:00
|
|
|
|
const composeEnhancers =
|
2018-06-25 17:42:50 +00:00
|
|
|
|
typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
2017-07-20 19:09:07 +00:00
|
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
2021-05-12 06:35:00 +00:00
|
|
|
|
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
|
|
|
|
|
})
|
2018-06-25 17:42:50 +00:00
|
|
|
|
: compose;
|
2016-11-16 17:18:39 +00:00
|
|
|
|
const middleware = [thunkMiddleware];
|
2017-07-20 19:09:07 +00:00
|
|
|
|
const enhancer = composeEnhancers(
|
2021-05-12 06:35:00 +00:00
|
|
|
|
applyMiddleware(...middleware), // other store enhancers if any
|
2017-07-20 19:09:07 +00:00
|
|
|
|
);
|
|
|
|
|
const store = createStore(reducer, enhancer);
|
2021-05-12 06:35:00 +00:00
|
|
|
|
|
2016-11-16 17:18:39 +00:00
|
|
|
|
if (__DEV__ && module.hot) {
|
|
|
|
|
module.hot.accept('./modules/index', () => {
|
2017-03-03 01:44:07 +00:00
|
|
|
|
store.replaceReducer(reducer);
|
2016-11-16 17:18:39 +00:00
|
|
|
|
});
|
2016-03-20 04:00:40 +00:00
|
|
|
|
}
|
2016-03-16 05:49:42 +00:00
|
|
|
|
|
2021-11-03 08:06:52 +00:00
|
|
|
|
return store as Store;
|
2016-03-20 04:00:40 +00:00
|
|
|
|
}
|