最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to retry only on certain error emitted by the source observable in RxJs - Stack Overflow

programmeradmin4浏览0评论

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;
        }
    });
});
发布评论

评论列表(0)

  1. 暂无评论