You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pull 3444 Completable class to support valueless event composition + tests
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 extend, 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:
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.
Version 1.1.1 - February 10, 2016 (Maven)
The new
Completable
classWhat is this Completable class?
We can think of a
Completable
object as a stripped version ofObservable
where only the terminal events,onError
andonCompleted
are ever emitted; they may look like anObservable.empty()
typified in a concrete class but unlikeempty()
,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
, theCompletable
behavior can be emulated withObservable<?>
to some extend, 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 anObservable
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
:Quite straightforward. We have a set of
fromXXX
method which can take many sources:Action
,Callable
,Single
and evenObservable
(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, arx.Subscriber
and arx.Completable.CompletableSubscriber
, the main intended receiver forCompletable
s.Further reading
API enhancements
API deprecations
cache(int)
via 1.x: Rename cache(int) to cacheWithInitialCapacity(int) #3498, replaced bycacheWithCapacityHint(int)
finallyDo(Action0)
via Deprecate Observable.finallyDo() and add Observable.doAfterTerminate() instead #3566, replaced bydoAfterTerminate(Action0)
Performance improvements
Bugfixes
The text was updated successfully, but these errors were encountered: