aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/store.js
blob: d9764a3fcf905a09529820a1bb0c7873fd67ce88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const createStore = require('redux').createStore
const applyMiddleware = require('redux').applyMiddleware
const thunkMiddleware = require('redux-thunk')
const rootReducer = require('./reducers')
const developmentMode = require('../../app/scripts/config').developmentMode

module.exports = configureStore

const middlewares = [thunkMiddleware]

console.log(developmentMode)
if (developmentMode) {
  console.log('Development Mode ON.')
  const createLogger = require('redux-logger')
  const loggerMiddleware = createLogger()
  middlewares.push(loggerMiddleware)
} else {
  console.log('Development Mode OFF.')
}


const createStoreWithMiddleware = applyMiddleware(...middlewares
)(createStore)

function configureStore (initialState) {
  return createStoreWithMiddleware(rootReducer, initialState)
}