git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: b817a22329dc2038d6896282542635e15961b37b

Files: b817a22329dc2038d6896282542635e15961b37b / app / store.js

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

Built with git-ssb-web