A srcObservable.retry() will catch the error emitted by the srcObservable and resubscribe to the srcObservable regardless of the type of the error. However, on certain scenario, it is wanted to only retry on certain type of error emitted by the srcObservable. Is there a way to do so in RxJs neatly?
A srcObservable.retry() will catch the error emitted by the srcObservable and resubscribe to the srcObservable regardless of the type of the error. However, on certain scenario, it is wanted to only retry on certain type of error emitted by the srcObservable. Is there a way to do so in RxJs neatly?
Share Improve this question edited Mar 19, 2015 at 17:12 Brandon 39.2k8 gold badges86 silver badges89 bronze badges asked Mar 19, 2015 at 0:34 victorxvictorx 3,5693 gold badges29 silver badges36 bronze badges1 Answer
Reset to default 10Try using retryWhen:
src.retryWhen(function (errors) {
// retry for some errors, end the stream with an error for others
return errors.do(function (e) {
if (!canRetry(e)) {
throw e;
}
});
});