2016-07-16 02:06:10 +00:00
|
|
|
import {createStore, applyMiddleware} 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
|
|
|
|
2016-04-29 03:37:49 +00:00
|
|
|
export default function configureStore () {
|
2016-11-16 17:18:39 +00:00
|
|
|
const middleware = [thunkMiddleware];
|
2016-04-29 05:58:37 +00:00
|
|
|
|
|
|
|
if (__DEV__) {
|
2016-11-27 21:42:38 +00:00
|
|
|
const createLogger = require('redux-logger');
|
|
|
|
middleware.push(createLogger({collapsed: true}));
|
2016-04-29 05:58:37 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 17:18:39 +00:00
|
|
|
const store = createStore(reducer, applyMiddleware(...middleware));
|
|
|
|
if (__DEV__ && module.hot) {
|
|
|
|
module.hot.accept('./modules/index', () => {
|
|
|
|
store.replaceReducer(require('./modules').reducer);
|
|
|
|
});
|
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
|
|
|
}
|