diff options
Diffstat (limited to 'frontend/app/site/store.js')
| -rw-r--r-- | frontend/app/site/store.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/frontend/app/site/store.js b/frontend/app/site/store.js new file mode 100644 index 0000000..a228e2b --- /dev/null +++ b/frontend/app/site/store.js @@ -0,0 +1,37 @@ +import { applyMiddleware, compose, combineReducers, createStore } from 'redux' +import { connectRouter, routerMiddleware } from 'connected-react-router' +import { createBrowserHistory } from 'history' +import thunk from 'redux-thunk' + +import siteReducer from './site/site.reducer' + +const createRootReducer = history => ( + combineReducers({ + auth: (state = {}) => state, + router: connectRouter(history), + site: siteReducer, + }) +) + +const configureStore = (initialState = {}, history) => { + const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose + + const store = createStore( + createRootReducer(history), + initialState, + composeEnhancers( + applyMiddleware( + thunk, + routerMiddleware(history) + ), + ), + ) + + return store +} + +const history = createBrowserHistory() +const store = configureStore({}, history) +const { dispatch } = store + +export { store, history, dispatch } |
