git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: e077e8e4d717d2c79b41f7287c20906ac86841db

Files: e077e8e4d717d2c79b41f7287c20906ac86841db / app / store.js

1367 bytesRaw
1const { createStore, compose, applyMiddleware } = require('redux')
2const thunk = require('redux-thunk')
3const logger = require('redux-logger')
4const { reduxReactRouter, routerStateReducer, ReduxRouter } = require('redux-router')
5const { createHistory } = require('history')
6
7const rootReducer = require('app/reducers')
8const routes = require('routes')
9
10let storesEnhancers = []
11let middleware = []
12
13middleware.push(thunk)
14
15if (process.env.NODE_ENV === 'development') {
16 var { persistState } = require('redux-devtools')
17
18 var DevTools = require('app/containers/dev-tools')
19
20 middleware.push(logger())
21}
22
23storesEnhancers.push(
24 applyMiddleware(...middleware)
25)
26
27if (process.env.NODE_ENV === 'development') {
28 storesEnhancers.push(DevTools.instrument())
29 storesEnhancers.push(persistState(
30 window.location.href.match(
31 /[?&]debug_session=([^&]+)\b/
32 )
33 ))
34}
35
36storesEnhancers.push(
37 reduxReactRouter({
38 routes, createHistory
39 })
40)
41
42const finalCreateStore = compose(
43 ...storesEnhancers
44)(createStore)
45
46function configureStore(initialState) {
47 const store = finalCreateStore(rootReducer, initialState)
48
49 if (process.env.NODE_ENV === 'development') {
50 if (module.hot) {
51 module.hot.accept('app/reducers', () =>
52 store.replaceReducer(require('app/reducers'))
53 )
54 }
55 }
56
57 return store
58}
59
60module.exports = configureStore
61
62

Built with git-ssb-web