如何延迟全部产量?

时间:2019-06-22 13:30:13

标签: redux-saga

如何在循环生成器中的每个映射中延迟?它的产量延迟工作1次。也许不应该是something.map

function* loop(param1, param2, param3) {
    try {
        const count = yield call(getCall, param1, param2)
        yield delay(150)
        return {
            id: param2,
            title: param3,
            count: param1
        }
    } catch (e) {
        console.log(e)
    }
}

function* saga(action) {
    try {
        yield put(setIsLoadingAction(true))
        const something = yield select(selectSomethig)
        //loop here
        const data = yield all(
            something.map((someth) => loop(action.payload, someth.id, someth.title))
        )
        yield put(setSomething(data))
        yield put(setIsLoadingAction(false))
    } catch (e) {
        console.log(e)
    }
}

0 个答案:

没有答案