【发布时间】:2018-04-16 01:18:57
【问题描述】:
redux saga 的新手 - 我正试图弄清楚当 我可以访问商店时如何在 redux 中间件环境之外调用 saga。
阅读 redux saga 文档后,我有两个选择,要么调用 store.runSaga,要么使用 redux-saga 提供的 runSaga 实用程序。
这就是我想要做的:
步骤:
- 创建了一个暂停直到成功操作被调度的 saga。
类似这样的:
export function* loadDashboardSequenced() {
try {
// Take pauses until action received.
//Wait for the user to be loaded
const user_success = yield take('FETCH_USER_SUCCESS');
// ....do other stuff....
} catch(error) {
yield put({type: 'FETCH_FAILED', error: error.message});
}
- 现在我尝试通过 store.runSaga https://redux-saga.js.org/docs/api/ 或 runSaga https://redux-saga.js.org/docs/api/index.html#runsagaoptions-saga-args 调用 saga
使用 runSaga 与 store.runSaga 有什么好处吗?我不确定此时我应该使用哪一个。有什么想法/建议吗?谢谢!
编辑:关于使用 runSaga https://redux-saga.js.org/docs/advanced/UsingRunSaga.html 的后续问题 这条线是什么意思
subscribe: ..., // this will be used to resolve take Effects
【问题讨论】:
标签: reactjs redux redux-thunk redux-saga