-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-store.js
48 lines (43 loc) · 1.13 KB
/
configure-store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { createStore, applyMiddleware, compose } from 'redux'
import rootReducer from 'ducks'
import thunk from 'redux-thunk'
import createLogger from 'redux-logger'
import Immutable from 'immutable'
import bootstrapStore from './bootstrap'
import analyticsMiddleware from './analytics-middleware'
const __DEVELOPMENT__ = process.env.NODE_ENV === 'development'
const middleware = [thunk, analyticsMiddleware]
let enhancers
if (__DEVELOPMENT__) {
middleware.push(createLogger({
collapsed: true,
stateTransformer (state) {
if (Immutable.Map.isMap(state) || Immutable.List.isList(state)) {
return state.toJS()
}
return state
}
}))
if (window.devToolsExtension) {
enhancers = compose(
applyMiddleware(...middleware),
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__() || window.devToolsExtension()
)
} else {
enhancers = applyMiddleware(...middleware)
}
} else {
enhancers = applyMiddleware(...middleware)
}
/**
* @function
* Create the store for redux
* @returns {object}
*/
export default function () {
return createStore(
rootReducer,
bootstrapStore(),
enhancers
)
}