2017-07-20 19:09:07 +00:00
|
|
|
|
import {createStore, applyMiddleware, compose} from 'redux';
|
2016-11-07 20:24:38 +00:00
|
|
|
|
import thunkMiddleware from 'redux-thunk';
|
2016-11-16 17:18:39 +00:00
|
|
|
|
import {reducer} from './modules';
|
2016-04-29 05:58:37 +00:00
|
|
|
|
|
2017-03-08 05:52:17 +00:00
|
|
|
|
export default function () {
|
2017-07-20 19:09:07 +00:00
|
|
|
|
const composeEnhancers =
|
|
|
|
|
typeof window === 'object' &&
|
|
|
|
|
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
|
|
|
|
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
|
|
|
|
|
}) : compose;
|
2016-11-16 17:18:39 +00:00
|
|
|
|
const middleware = [thunkMiddleware];
|
2017-07-20 19:09:07 +00:00
|
|
|
|
const enhancer = composeEnhancers(
|
2017-11-20 16:07:36 +00:00
|
|
|
|
applyMiddleware(...middleware)
|
2017-07-20 19:09:07 +00:00
|
|
|
|
// other store enhancers if any
|
|
|
|
|
);
|
|
|
|
|
const store = createStore(reducer, enhancer);
|
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
|
|
|
|
|
2016-04-26 07:29:24 +00:00
|
|
|
|
return store;
|
2016-03-20 04:00:40 +00:00
|
|
|
|
}
|