2016-04-14 00:28:44 +02:00
|
|
|
const createStore = require('redux').createStore
|
|
|
|
const applyMiddleware = require('redux').applyMiddleware
|
2017-08-08 23:15:45 +02:00
|
|
|
const thunkMiddleware = require('redux-thunk').default
|
2016-04-14 00:28:44 +02:00
|
|
|
const rootReducer = require('./reducers')
|
2017-08-08 23:15:45 +02:00
|
|
|
const createLogger = require('redux-logger').createLogger
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2018-04-03 18:51:33 +02:00
|
|
|
global.METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
2016-08-12 03:58:23 +02:00
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
module.exports = configureStore
|
|
|
|
|
2016-08-12 03:58:23 +02:00
|
|
|
const loggerMiddleware = createLogger({
|
2016-08-12 04:04:50 +02:00
|
|
|
predicate: () => global.METAMASK_DEBUG,
|
2016-08-12 03:58:23 +02:00
|
|
|
})
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2016-08-12 03:58:23 +02:00
|
|
|
const middlewares = [thunkMiddleware, loggerMiddleware]
|
2016-08-11 22:59:14 +02:00
|
|
|
|
2016-08-11 23:22:48 +02:00
|
|
|
const createStoreWithMiddleware = applyMiddleware(...middlewares)(createStore)
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
function configureStore (initialState) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return createStoreWithMiddleware(rootReducer, initialState)
|
|
|
|
}
|