How to wait execution of a saga to finish in redux-saga?
As per your code snippet, your addCircle
saga will dispatch either addCircleFailedAction
or addCircleSucceededAction
action creators just before it finishes execution. So we will have to wait for those action in your addTender
saga.
Basically, this is what you should do. I'm just guessing your action types based on action creator names.
yield call(addCircleAction(payload.circlePayload));
yield take([ADD_CIRCLE_FAILED_ACTION, ADD_CIRCLE_SUCCEEDED_ACTION]);
// Rest of the saga
There is one edge case though. You are not dispatching any action in the catch
block of your addCircle
saga. Maybe you can dispatch an action called addCircleExceptionAction
inside catch
block and wait for it along with the other actions like this:
yield take([ADD_CIRCLE_FAILED_ACTION, ADD_CIRCLE_SUCCEEDED_ACTION, ADD_CIRCLE_EXCEPTION_ACTION]);