Rxjava allows multiple onerror calls
•
Java
I tried to allow unlimited flow on the next and wrong call
The following code uses the retry () method. I assume that it allows me to see all three calls to onnext, but there are no other calls after the error
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 allows me to subscribe and take action on all errors and all next calls to the subject / observable
I also tried to implement the solution using custom operators, as shown in here, but I didn't have luck
Whether it is possible to implement what I want to do, or whether the onerror design of rxjava will break the chain and completely prevent this idea
Solution
This is not possible as described in rxjava discussion
If the error should not terminate the stream, wrap the error in the message through onnext
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码