Files: 3582ba8ad59f6e36f60142e530d0794c1e02c095 / app / store.js
1022 bytesRaw
1 | const { createStore, compose, applyMiddleware } = require('redux') |
2 | const thunk = require('redux-thunk') |
3 | const { createHistory } = require('history') |
4 | |
5 | const reducer = require('app/reducers') |
6 | |
7 | let storeEnhancers = [] |
8 | let middleware = [] |
9 | |
10 | middleware.push(thunk) |
11 | |
12 | if (process.env.NODE_ENV === 'development') { |
13 | var logger = require('redux-logger') |
14 | var { persistState } = require('redux-devtools') |
15 | |
16 | var DevTools = require('app/components/dev-tools') |
17 | } |
18 | |
19 | storeEnhancers.push( |
20 | applyMiddleware(...middleware) |
21 | ) |
22 | |
23 | if (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 | |
38 | const createEnhancedStore = compose( |
39 | ...storeEnhancers |
40 | )(createStore) |
41 | |
42 | function finalCreateStore(initialState) { |
43 | return createEnhancedStore(reducer, initialState) |
44 | } |
45 | |
46 | module.exports = finalCreateStore |
47 |
Built with git-ssb-web