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 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 => {
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue