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
A slight modification of the solution (@MikeN) to enable finite streams to complete:
import rx.Observable.Operator;
import rx.functions.Action1;
public final class OperatorSuppressError implements Operator {
final Action1 onError;
public OperatorSuppressError(Action1 onError) {
this.onError = onError;
}
@Override
public Subscriber super T> call(final Subscriber super T> t1) {
return new Subscriber(t1) {
@Override
public void onNext(T t) {
t1.onNext(t);
}
@Override
public void onError(Throwable e) {
onError.call(e);
//this will allow finite streams to complete
t1.onCompleted();
}
@Override
public void onCompleted() {
t1.onCompleted();
}
};
}
}