RxJava - Can I Bypass onSuccess and only have an onError option?

172 Views Asked by At

I am creating a Disposable:

myDisposable = myObservableMethod().subscribe(this::mySuccess, this::myError);

In this case, if myObservableMethod() returns a success, there is nothing more that I need to do, so mySuccess() is and empty method and exists for no reason.

I have tried this:

myDisposable = myObservableMethod().doOnError(this::myError).subscribe();

but am getting crashes.

Is there anyway to call this without needing an onSuccess ?

1

There are 1 best solutions below

0
On BEST ANSWER

You have crash because you don't handle the error, exception is thrown to the upper level and crashes with unhandling exception.

You could place empty lambda in place

... subscribe(ignore -> {}, this::myError)