2017-08-22 00:10:52 +02:00
|
|
|
import {
|
|
|
|
applyMiddleware,
|
|
|
|
createStore,
|
|
|
|
compose
|
|
|
|
} from 'redux';
|
|
|
|
import thunk from 'redux-thunk';
|
2017-08-24 14:30:22 +02:00
|
|
|
import createHistory from 'history/createBrowserHistory';
|
|
|
|
import { routerMiddleware, push } from 'react-router-redux'
|
2017-08-20 17:57:57 +02:00
|
|
|
import reducer from './reducers';
|
|
|
|
|
2017-08-24 14:30:22 +02:00
|
|
|
export const history = createHistory();
|
|
|
|
|
2017-08-22 00:10:52 +02:00
|
|
|
const _compose =
|
|
|
|
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
|
|
|| compose;
|
2017-08-20 17:57:57 +02:00
|
|
|
const store = createStore(
|
|
|
|
reducer,
|
2017-08-24 14:30:22 +02:00
|
|
|
_compose(applyMiddleware(thunk, routerMiddleware(history))),
|
2017-08-20 17:57:57 +02:00
|
|
|
);
|
|
|
|
|
2017-08-25 03:46:55 +02:00
|
|
|
if (module.hot) {
|
|
|
|
// Enable webpack hot module replacement for reducers
|
|
|
|
module.hot.accept(
|
|
|
|
'./reducers',
|
|
|
|
() => store.replaceReducer(reducers)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-08-22 00:10:52 +02:00
|
|
|
export const dispatch = action => store.dispatch(action);
|
2017-08-25 03:13:01 +02:00
|
|
|
export const getState = () => store.getState();
|
2017-08-22 00:10:52 +02:00
|
|
|
|
2017-08-20 17:57:57 +02:00
|
|
|
export default store;
|