I have a case that I have to call n sagas:
function* mainSaga() {
yield all(
someArrayOfIds.map((id) => call(pollSaga, id))
)
}
pollSaga:
function* pollSaga(id) {
yield race([
call(workSaga, id)
take('STOP_ACTION')
])
}
workSaga:
function* workSaga(id) {
while (true) {
yield call(...);
yield delay(...)
}
}
The thing im super struggling here, is how to know when all of the pollSagas have finished. As you can see in the pollSaga
I can just dispatch the STOP_ACTION
but this is useless since it will stop ALL of the sagas (I dont want to stop all the sagas at once).
Difficult for me to properly explain the goal here, but if you are experienced with sagas you will know what I mean. I just want to be able to differentiate between pollSaga
calls and to be able to stop each of them separately and somehow “listen” when ALL of them have finished.
Maybe there is a way if I dispatch STOP_ACTION
only that specified pollSaga will be cancelled, not all of them?