receptor/src/store.js

33 lines
769 B
JavaScript
Raw Normal View History

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();
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
);
if (module.hot) {
// Enable webpack hot module replacement for reducers
module.hot.accept(
'./reducers',
() => store.replaceReducer(reducers)
);
}
export const dispatch = action => store.dispatch(action);
export const getState = () => store.getState();
2017-08-20 17:57:57 +02:00
export default store;