2016-02-25 00:45:56 -08:00
|
|
|
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
|
|
|
|
import thunkMiddleware from 'redux-thunk';
|
|
|
|
import { browserHistory } from 'react-router';
|
|
|
|
import { syncHistory, routeReducer } from 'react-router-redux';
|
2016-06-10 00:16:01 -03:00
|
|
|
import reducers from '../reducers';
|
2016-02-25 00:45:56 -08:00
|
|
|
|
|
|
|
const reducer = combineReducers({
|
2016-06-10 00:16:01 -03:00
|
|
|
...reducers,
|
2016-02-25 00:45:56 -08:00
|
|
|
router: routeReducer
|
|
|
|
});
|
|
|
|
|
|
|
|
const createStoreWithMiddleware = compose(
|
|
|
|
applyMiddleware(thunkMiddleware, syncHistory(browserHistory)),
|
|
|
|
window.devToolsExtension ? window.devToolsExtension() : (f) => f
|
|
|
|
)(createStore);
|
|
|
|
|
|
|
|
export default (initialState) => (
|
|
|
|
createStoreWithMiddleware(reducer, initialState)
|
|
|
|
);
|