mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
recreate stdChannel (or saga middleware). (#6330)
This commit is contained in:
parent
9f2eb85de3
commit
f9fedaeba6
|
@ -1,11 +1,9 @@
|
|||
import { createStore, applyMiddleware } from 'redux'
|
||||
import { applyMiddleware, createStore } from 'redux'
|
||||
import createSagaMiddleware from 'redux-saga'
|
||||
|
||||
import rootReducer, { exampleInitialState } from './reducer'
|
||||
import rootSaga from './saga'
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware()
|
||||
|
||||
const bindMiddleware = middleware => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const { composeWithDevTools } = require('redux-devtools-extension')
|
||||
|
@ -15,17 +13,15 @@ const bindMiddleware = middleware => {
|
|||
}
|
||||
|
||||
function configureStore (initialState = exampleInitialState) {
|
||||
const sagaMiddleware = createSagaMiddleware()
|
||||
const store = createStore(
|
||||
rootReducer,
|
||||
initialState,
|
||||
bindMiddleware([sagaMiddleware])
|
||||
)
|
||||
|
||||
store.runSagaTask = () => {
|
||||
store.sagaTask = sagaMiddleware.run(rootSaga)
|
||||
}
|
||||
store.sagaTask = sagaMiddleware.run(rootSaga)
|
||||
|
||||
store.runSagaTask()
|
||||
return store
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue