I'm attempting to allow for an infinite stream of both on next and on error calls.
The below code uses the retry()
method which I assumed would allow me to see all 3 calls to onNext
however after the error nothing else is called.
public class TesterClass {
public static void main(final String[] args) {
final PublishSubject<Void> publishSubject = PublishSubject.create();
publishSubject
.retry()
.subscribe(
aVoid -> System.out.println("onNext"),
Throwable::printStackTrace,
() -> System.out.println("onComplete")
);
publishSubject.onNext(null);
publishSubject.onNext(null);
publishSubject.onError(new Exception("onError"));
publishSubject.onNext(null);
}
}
My ideal use case would allow me to subscribe and take action on all errors and all next calls from the subject / observable.
I've also attempted to implement a solution using a custom Operator
as shown here but I've had no luck with this either.
Is it a possibility to achieve what I'm setting out to do or does the design of RxJava's onError breaking the chain completely block this idea.