Skip to content

Completable.subscribe(onError, onComplete) design issue #3851

Closed
@artem-zinnatullin

Description

@artem-zinnatullin

This particular overload of Completable.subscribe() looks out of design in compare to other RxJava classes like Observable and Single.

Spent ~5 minutes trying to understand why such code didn't compile:

Completable
  .fromAction(() -> doSomething())
  .subscribe(
    () -> ui.success(), 
    error -> ui.error(error)
  );

And the reason is because this overload accepts error handler first and complete handler second.

I do understand that it comes from Observable.subscribe(onNext, onError, onComplete).

But in compare to many other overloads like:

  • Observable.subscribe(onNext, onError)
  • Single.subscribe(onSuccess, onError) // this one has very similar semantic to target overload.
  • Observable.subscribe(onNext)
  • Single.subscribe(onSuccess)

Error handler is never first parameter in Observable.subscribe() and Single.subscribe().

Another point is that compiler error displayed in IDE makes it even worse:
screen shot 2016-04-12 at 00 35 50


Completable is still in @Experimental, so, we can change this signature as we want. We can @Deprecate this overload and add "better" alternative and then delete deprecated overload after one-two releases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions