I'd like to run parallel effects with redux-saga, without throwing if an error happens.
Using the all
effect from redux-saga, if:
One of the Effects was rejected before all the effects complete: throws the rejection error inside the Generator.
Basically, I want to wait for all effects to finish to trigger an action. I want to do something like this, but replacing all
by something else:
export function* getSaga() {
yield put(request());
try {
yield all([fetchItems1, fetchItems2, fetchItems3]);
// Wait for all to resolve or get rejected, then dispatch succeed.
yield put(actions.succeeded());
} catch (e) {
// This should never happen.
}
}
I tried to use fork
but it does cancel all other tasks if one failed. And I tried to use spawn
but it doesn't wait for the tasks to finish to dispatch succeeded
.
Using regular JS, there is a pattern called reflect which I'd like to apply with saga.
How can we achieve that?
Thanks