T
- the value typepublic final class OperatorOnErrorReturn<T> extends java.lang.Object implements Observable.Operator<T,T>
onNext
method
rather than invoking onError
if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected
item to its Observer, the Observable invokes its Observer's onError
method, and then
quits without invoking any more of its Observer's methods. The onErrorReturn operation changes
this behavior. If you pass a function (resumeFunction) to onErrorReturn, if the original
Observable encounters an error, instead of invoking its Observer's onError
method,
it will instead pass the return value of resumeFunction to the Observer's onNext
method.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
Constructor and Description |
---|
OperatorOnErrorReturn(Func1<java.lang.Throwable,? extends T> resultFunction) |
Modifier and Type | Method and Description |
---|---|
Subscriber<? super T> |
call(Subscriber<? super T> child) |
public Subscriber<? super T> call(Subscriber<? super T> child)
call
in interface Func1<Subscriber<? super T>,Subscriber<? super T>>