2017-11-13 19:37:43 +00:00
|
|
|
import { createStore, applyMiddleware } from 'redux'
|
|
|
|
import { createLogger } from 'redux-logger'
|
2018-02-04 11:56:32 +00:00
|
|
|
import { createEpicMiddleware } from 'redux-observable'
|
|
|
|
import reducer from './reducer'
|
|
|
|
import { rootEpic } from './epics'
|
2017-11-13 19:37:43 +00:00
|
|
|
|
|
|
|
export default function initStore (initialState) {
|
2018-07-21 23:37:59 +00:00
|
|
|
const epicMiddleware = createEpicMiddleware()
|
2018-03-27 18:11:03 +00:00
|
|
|
const logger = createLogger({ collapsed: true }) // log every action to see what's happening behind the scenes.
|
2018-07-21 23:37:59 +00:00
|
|
|
const reduxMiddleware = applyMiddleware(epicMiddleware, logger)
|
2017-11-13 19:37:43 +00:00
|
|
|
|
2018-07-21 23:37:59 +00:00
|
|
|
const store = createStore(reducer, initialState, reduxMiddleware)
|
|
|
|
epicMiddleware.run(rootEpic)
|
|
|
|
|
|
|
|
return store
|
2018-12-17 16:34:32 +00:00
|
|
|
}
|