I have the following retry logic to retry an operation. It works fine for single request. For multiple on going requests, I would like to wait for existing retry logic to complete before retrying.
handleError(errors: Observable<any>) {
const retryCountStart: number = 1;
// wait if there is any existing operation retrying
// once it is complete, continue here
return errors
.mergeScan<any, any>(
(retryCount: any, err: any) => {
if (retryCount <= 5) {
return Observable.of(retryCount + 1);
}
},retryCountStart)
.delay(1000);
}
How can I add delay until some condition is met in the above method?