aboutsummaryrefslogblamecommitdiffstats
path: root/ui/app/store.js
blob: 30618e4f8c9362446dc5261320b471bb8a944a19 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                                        
                                         
                                                                           
                                            


                               
                                     
 
                      
                                     

                                         


 
                                                                              
 
                                        

                                                             
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
const createLogger = require('redux-logger')

module.exports = configureStore

const middlewares = [thunkMiddleware]

if (developmentMode) {
  console.log('Development Mode ON.')
  const loggerMiddleware = createLogger()
  middlewares.push(loggerMiddleware)
}


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

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