How to ignore error and continue infinite stream?

后端 未结 10 1752
执念已碎
执念已碎 2020-12-05 06:18

I would like to know how to ignore exceptions and continue infinite stream (in my case stream of locations)?

I\'m fetching current user position (using Android-React

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 07:09

    You may want to use one of the error handling operators.

    • onErrorResumeNext( ) — instructs an Observable to emit a sequence of items if it encounters an error
    • onErrorReturn( ) — instructs an Observable to emit a particular item when it encounters an error
    • onExceptionResumeNext( ) — instructs an Observable to continue emitting items after it encounters an exception (but not another variety of throwable)
    • retry( ) — if a source Observable emits an error, resubscribe to it in the hopes that it will complete without error
    • retryWhen( ) — if a source Observable emits an error, pass that error to another Observable to determine whether to resubscribe to the source

    Especialy retry and onExceptionResumeNext look promising in your case.

提交回复
热议问题