还原。如何使用 redux-saga 运行 sagaMiddleWare.run([ f1*(), f2*(), f3*() ]) 中的多个 sagas?
Redux. How to run several sagas in sagaMiddleWare.run([ f1*(), f2*(), f3*() ]) with redux-saga?
我需要在不同时间点启动多个传奇的解决方案。我创建了 3 个不同的传奇,并尝试将它们实现到 sagaMiddleWare.run()
就像一个数组。但是现在我得到一个错误 - runSaga(storeInterface, saga, ...args): saga argument must be a Generator function!
。
我明白为什么会出现这个错误,但不明白如何解决?
谢谢!
sagaMiddleWare.run([watchSearchForCash, watchBootlegging, watchGraffiti])
您可以通过将所有 sagas 合并到一个包装中使其更容易工作,称为(例如)rootSaga
:
function * rootSaga() {
yield [
watchSearchForCash,
watchBootlegging,
watchGraffiti
]
}
然后在 sagaMiddleWare.run(rootSaga)
中实施新的 saga holder rootSaga
这就是所有的魔法:)
我需要在不同时间点启动多个传奇的解决方案。我创建了 3 个不同的传奇,并尝试将它们实现到 sagaMiddleWare.run()
就像一个数组。但是现在我得到一个错误 - runSaga(storeInterface, saga, ...args): saga argument must be a Generator function!
。
我明白为什么会出现这个错误,但不明白如何解决?
谢谢!
sagaMiddleWare.run([watchSearchForCash, watchBootlegging, watchGraffiti])
您可以通过将所有 sagas 合并到一个包装中使其更容易工作,称为(例如)rootSaga
:
function * rootSaga() {
yield [
watchSearchForCash,
watchBootlegging,
watchGraffiti
]
}
然后在 sagaMiddleWare.run(rootSaga)
rootSaga
这就是所有的魔法:)