【发布时间】:2020-11-27 14:00:15
【问题描述】:
如何让 watcher saga 仅在动作模式的第一次调度时触发 worker saga?
function* rootSaga() {
yield takeEvery(CHATBOT.START, handleChatbotLoad); //I want watcher saga to trigger handleChatbotLoad only on the very first dispatch of CHATBOT.START
yield takeEvery(CONVERSATION.ADD_QUERY, handleUserInput);
}
所以,我希望 watcher saga 仅在第一次发送 CHATBOT.START 时触发 handleChatbotLoad。我可以在started 之类的状态下设置一个标志,并且只发送一次 CHATBOT.START。
但后来我期待像takeFirst 这样的方法或类似的方法。有没有这样的方法可以做到这一点?
【问题讨论】:
标签: redux redux-saga react-redux-i18n