我对redux-sage有问题。无法设法订阅动作。 我有此商店设置
import { createStore, applyMiddleware, compose } from "redux"
import createSagaMiddleware from "redux-saga"
import rootSaga from "../config/rootSaga"
import rootReducer from "../config/rootReducer"
const effects = []
let composeEnhancers = compose
if (process.env.NODE_ENV === "development") {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ // eslint-disable-line no-underscore-dangle
}
const sagaMiddleware = createSagaMiddleware()
effects.push(sagaMiddleware)
const store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(...effects)))
sagaMiddleware.run(rootSaga)
export default store
像佐贺中间件外貌不起作用。 我看到的console.log从我rootSaga但当Redux的作用正在发生的传奇不起作用
export default function* searchRootSaga() {
console.log("searchRootSaga") // I see this on start
yield all([fork(throttle, 100, SEARCH.GET.REQUEST, getSearchThis)])
}
export function* getSearchThis(action) {
console.log("getSearchThis") // I dont see this
try {
// const response = yield call(API.getSearch, query)
const response = dummy_data
yield put(getSearchSuccess(response))
} catch (e) {
yield put(getSearchFailure("Server Err"))
}
}
React开发工具显示SEARCH.GET.REQUEST动作,但Saga无法正常运行。 我在做什么错了?
答案 0 :(得分:2)
我认为节流本身就是一种非阻塞效应。因此,您无需进行分叉。试试:
yield throttle(100, SEARCH.GET.REQUEST, getSearchThis)