git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 5aaa7567ce018bfe4ea54d34371929683870a809

Files: 5aaa7567ce018bfe4ea54d34371929683870a809 / app / store.js

1164 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 if (process.browser) {
23 storeEnhancers.push(
24 applyMiddleware(logger())
25 )
26 }
27
28 storeEnhancers.push(DevTools.instrument())
29
30 if (module.browser) {
31 let { persistState } = require('redux-devtools')
32 storeEnhancers.push(persistState(
33 window.location.href.match(
34 /[?&]debug_session=([^&]+)\b/
35 )
36 ))
37 }
38}
39
40const createEnhancedStore = compose(
41 ...storeEnhancers
42)(createStore)
43
44export default function finalCreateStore(initialState) {
45 const store = createEnhancedStore(reducer, initialState)
46
47 if (module.hot) {
48 module.hot.accept('app/reducer', () => {
49 store.replaceReducer(require('app/reducer'))
50 })
51 }
52
53 return store
54}
55

Built with git-ssb-web