Commit f9fedaeb authored by Timon Borter's avatar Timon Borter Committed by Tim Neutkens

recreate stdChannel (or saga middleware). (#6330)

parent 9f2eb85d
import { createStore, applyMiddleware } from 'redux' import { applyMiddleware, createStore } from 'redux'
import createSagaMiddleware from 'redux-saga' import createSagaMiddleware from 'redux-saga'
import rootReducer, { exampleInitialState } from './reducer' import rootReducer, { exampleInitialState } from './reducer'
import rootSaga from './saga' import rootSaga from './saga'
const sagaMiddleware = createSagaMiddleware()
const bindMiddleware = middleware => { const bindMiddleware = middleware => {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
const { composeWithDevTools } = require('redux-devtools-extension') const { composeWithDevTools } = require('redux-devtools-extension')
...@@ -15,17 +13,15 @@ const bindMiddleware = middleware => { ...@@ -15,17 +13,15 @@ const bindMiddleware = middleware => {
} }
function configureStore (initialState = exampleInitialState) { function configureStore (initialState = exampleInitialState) {
const sagaMiddleware = createSagaMiddleware()
const store = createStore( const store = createStore(
rootReducer, rootReducer,
initialState, initialState,
bindMiddleware([sagaMiddleware]) bindMiddleware([sagaMiddleware])
) )
store.runSagaTask = () => { store.sagaTask = sagaMiddleware.run(rootSaga)
store.sagaTask = sagaMiddleware.run(rootSaga)
}
store.runSagaTask()
return store return store
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment