git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: ee357b9441a7fbb11be1a0d26b0a899624a2b155

Files: ee357b9441a7fbb11be1a0d26b0a899624a2b155 / app / store.js

1388 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 reducer = require('app/reducers')
8const routes = require('routes')
9
10let storeEnhancers = []
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/components/dev-tools')
19}
20
21storeEnhancers.push(
22 applyMiddleware(...middleware)
23)
24
25storeEnhancers.push(
26 reduxReactRouter({
27 routes, createHistory
28 })
29)
30
31if (process.env.NODE_ENV === 'development') {
32
33 storeEnhancers.push(
34 applyMiddleware(logger())
35 )
36 storeEnhancers.push(DevTools.instrument())
37 storeEnhancers.push(persistState(
38 window.location.href.match(
39 /[?&]debug_session=([^&]+)\b/
40 )
41 ))
42}
43
44const createEnhancedStore = compose(
45 ...storeEnhancers
46)(createStore)
47
48function configureStore(initialState) {
49 const store = createEnhancedStore(reducer, initialState)
50
51 if (process.env.NODE_ENV === 'development') {
52 if (module.hot) {
53 module.hot.accept('app/reducers', () =>
54 store.replaceReducer(require('app/reducers'))
55 )
56 }
57 }
58
59 return store
60}
61
62module.exports = configureStore
63
64

Built with git-ssb-web