1
这是我的传奇现在:参数传递到佐贺调度 - 并获得参数的处理程序
function* upAsyncSaga() {
yield takeEvery(UP_ASYNC, upAsyncHandler);
}
这里是相关的同步材料:
const UP_ASYNC = 'UP_ASYNC';
export function upAsync() {
return {
type: UP_ASYNC
}
}
function* upAsyncHandler() {
yield call(wait, 1000);
yield put(up());
}
const UP = 'UP';
export function up() {
return {
type: UP
}
}
我触发upAsyncSaga
通过这样做store.dispatch(upAsync())
。不过,我想通过一个名为times
的论点。所以我想要做的store.dispatch(upAsync(3))
,然后我希望/希望拿到参数的处理这样的伪代码:
export function upAsync(times) { // this is the argument "times"
return {
type: UP_ASYNC
times // here it is again
}
}
function* upAsyncHandler(times) { // i want the argument to get to the handler
for (let i=0; i<times; i++) {
yield call(wait, 1000);
yield put(up());
}
}
这可能吗?
谢谢Umesh,但我怎么能得到'有效载荷'到'upAsyncHandler'? – Blagoh
非常感谢,我现在终于明白了。请原谅我延迟接受您的解决方案。 – Blagoh