1

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 ?

Chris
  • 5,485
  • 15
  • 68
  • 130
  • 2
    Use a static empty consumer instance: `public static final Consumer emptyConsumer = o -> { };` so you don't need to define empty methods/lambdas all over the place. – akarnokd Aug 17 '18 at 19:50

1 Answers1

1

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)
dilix
  • 3,761
  • 3
  • 31
  • 55