Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the new Completable Observable-like variant #164

Open
DavidMGross opened this issue Dec 2, 2015 · 11 comments
Open

Document the new Completable Observable-like variant #164

DavidMGross opened this issue Dec 2, 2015 · 11 comments

Comments

@DavidMGross
Copy link
Collaborator

It's still being discussed, but it seems like they're leaning toward adding this operator under some name or other to 1.x. See ReactiveX/RxJava#3443

@DavidMGross DavidMGross changed the title Document ignoreElementsThen operator (or whatever it ends up being called) Document ignoreElementsThen operator (or andThen or Completable or...) Dec 8, 2015
@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3444 (Completable)

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3567 (toCompletable / Completable.fromObservable)

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3568 (Completable.doAfterTerminate)

@DavidMGross
Copy link
Collaborator Author

DavidMGross commented Dec 10, 2015

See also:

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3580 (Completable review)

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3701 (change name of doOnComplete to doOnCompleted)

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3706 (lifecycle of Singles and Completables compared to Observables)

@DavidMGross DavidMGross changed the title Document ignoreElementsThen operator (or andThen or Completable or...) Document the new Completable Observable-like variant Feb 15, 2016
@DavidMGross
Copy link
Collaborator Author

From the RxJava 1.1.1 release notes:

What is this Completable class?

We can think of a Completable object as a stripped version of Observable where only the terminal events, onError and onCompleted are ever emitted; they may look like an Observable.empty() typified in a concrete class but unlike empty(), Completable is an active class. Completable mandates side effects when subscribed to and it is its main purpose indeed. Completable contains some deferred computation with side effects and only notifies about the success or failure of such computation.

Similar to Single, the Completable behavior can be emulated with Observable<?> to some extent, but many API designers think codifying the valuelessness in a separate type is more expressive than messing with wildcards (and usually type-variance problems) in an Observable chain.

Completable doesn't stream a single value, therefore, it doesn't need backpressure, simplifying the internal structure from one perspective, however, optimizing these internals requires more lock-free atomics knowledge in some respect.

Hello World!

Let's see how one can build a (side-effecting) Hello World Completable:

Completable.fromAction(() -> System.out.println("Hello World!"))
.subscribe();

Quite straightforward. We have a set of fromXXX method which can take many sources: Action, Callable, Single and even Observable (stripping any values generated by the latter 3 of course). On the receiving end, we have the usual subscribe capabilities: empty, lambdas for the terminal events, a rx.Subscriber and a rx.Completable.CompletableSubscriber, the main intended receiver for Completables.

Further reading

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxJava#3730 (Completable.andThen)

@DavidMGross
Copy link
Collaborator Author

See also: ReactiveX/RxKotlin#48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant