Skip to content
Snippets Groups Projects
Commit 62b088f5 authored by esikkala's avatar esikkala
Browse files

Configure the Redux store in a separate file

parent 7d52780b
No related branches found
No related tags found
No related merge requests found
import { createStore, applyMiddleware, compose, bindActionCreators } from 'redux'
import { createEpicMiddleware } from 'redux-observable'
import { actions as toastrActions } from 'react-redux-toastr'
import reducer from './reducers'
import rootEpic from './epics'
export default function configureStore (preloadedState) {
const epicMiddleware = createEpicMiddleware()
const middlewares = [epicMiddleware]
// https://github.com/zalmoxisus/redux-devtools-extension#11-basic-store
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const composedEnhancers = composeEnhancers(
applyMiddleware(...middlewares)
// other store enhancers could be added here
)
const store = createStore(reducer, preloadedState, composedEnhancers)
epicMiddleware.run(rootEpic)
bindActionCreators(toastrActions, store.dispatch)
return store
}
import React from 'react' import React from 'react'
import { render } from 'react-dom' import { render } from 'react-dom'
import { createStore, applyMiddleware, compose, bindActionCreators } from 'redux'
import { createEpicMiddleware } from 'redux-observable'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import ReduxToastr, { actions as toastrActions } from 'react-redux-toastr' import ReduxToastr from 'react-redux-toastr'
import { Router } from 'react-router-dom' import { Router } from 'react-router-dom'
import history from './History' import history from './History'
import reducer from './reducers' import configureStore from './configureStore'
import rootEpic from './epics'
import App from './components/App' import App from './components/App'
import { availableLocales } from './epics/index.js' import { availableLocales } from './epics/index.js'
import { loadLocales } from './actions' import { loadLocales } from './actions'
...@@ -19,22 +16,7 @@ import 'react-sortable-tree/style.css' ...@@ -19,22 +16,7 @@ import 'react-sortable-tree/style.css'
import 'react-redux-toastr/lib/css/react-redux-toastr.min.css' import 'react-redux-toastr/lib/css/react-redux-toastr.min.css'
import 'mapbox-gl/dist/mapbox-gl.css' import 'mapbox-gl/dist/mapbox-gl.css'
const epicMiddleware = createEpicMiddleware() const store = configureStore()
const middleware = applyMiddleware(epicMiddleware)
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(
reducer,
compose(
composeEnhancers(middleware)
)
)
epicMiddleware.run(rootEpic)
bindActionCreators(toastrActions, store.dispatch)
// init locale // init locale
const localeFromUrl = window.location.pathname.substr(1, 2) const localeFromUrl = window.location.pathname.substr(1, 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment