git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 99bc16e5212f7086422943407911f7c31443ab4c

Files: 99bc16e5212f7086422943407911f7c31443ab4c / app / store.js

1129 bytesRaw
1import { createStore, compose, applyMiddleware } from 'redux'
2import thunk from 'redux-thunk'
3import { createHistory } from 'history'
4
5import reducer from 'app/reducer'
6
7if (process.env.NODE_ENV === 'development') {
8 var logger = require('redux-logger')
9 var DevTools = require('app/dev/tools').default
10}
11
12let storeEnhancers = []
13let middleware = []
14
15middleware.push(thunk)
16
17storeEnhancers.push(
18 applyMiddleware(...middleware)
19)
20
21if (process.env.NODE_ENV === 'development') {
22 storeEnhancers.push(
23 applyMiddleware(logger())
24 )
25
26 storeEnhancers.push(DevTools.instrument())
27
28 if (module.browser) {
29 let { persistState } = require('redux-devtools')
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
42export default function finalCreateStore(initialState) {
43 const store = createEnhancedStore(reducer, initialState)
44
45 if (module.hot) {
46 module.hot.accept('app/reducer', () => {
47 store.replaceReducer(require('app/reducer'))
48 })
49 }
50
51 return store
52}
53

Built with git-ssb-web