admin管理员组

文章数量:1402919

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 badges
Add a ment  | 

1 Answer 1

Reset to default 10

Try 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;
        }
    });
});

本文标签: javascriptHow to retry only on certain error emitted by the source observable in RxJsStack Overflow