git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 633cd4d6f79cffbdfd1447900ad74313781e01f9

Files: 633cd4d6f79cffbdfd1447900ad74313781e01f9 / app / store.js

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

Built with git-ssb-web