Completable empty = (completableSubscriber -> { The Completable API follows the concepts of the Reactive-Streams. Create, Lift and Transform. The Completable class has three additional standard helper interfaces, now becoming common with all RxJava. Creating a Single. Completable. Creating a Completable. Maybe. Creating a Maybe. RxCocoa traits. Driver. Why is it named Driver; Practical usage example.

Author: Faurg Magis
Country: Mozambique
Language: English (Spanish)
Genre: Medical
Published (Last): 22 November 2015
Pages: 295
PDF File Size: 8.42 Mb
ePub File Size: 18.10 Mb
ISBN: 872-8-14102-470-9
Downloads: 14793
Price: Free* [*Free Regsitration Required]
Uploader: Nazahn

Note that the onFinally action is shared between subscriptions and as such should be thread-safe. The first set of operators is accessible as a static method and usually deal with a set of Completable s.

Have you considered whether you actually need to know about those 3 events every time? Returns a Completable that runs this Completable comp,etable emits a TimeoutException in case this Completable doesn’t complete within the given time while “waiting” on the specified Scheduler.

Clearer RxJava intentions with Single and Completable

I don’t think there are too many ways one can transform a Completable “sequence”. There is no need to call any of the plugin hooks on the current Completable instance or the CompletableObserver ; all hooks and basic safeguards have been applied by subscribe CompletableObserver before this method gets called. Completable is more like a type-tool to indicate a sequence won’t have any value but only side-effects and the reduced API surface may be more convenient than working with the full-blowin Observable API.

With the first operator, we’d like to suppress an exception and since there are no values involved, the best we can do is to signal an onCompleted ourselves:.

Returns a Completable that when this Completable emits an error, retries at most the given number of times before giving up and emitting the last error.


Returns a Completable that subscribes to a limited cdeate of inner Completables at once in the source sequence and delays any error emitted by either the sources observable or any of the inner Completables until all of them terminate in a way or another. If both this and the other sources signal an error, only one of the errors is signaled to the downstream and the other error is signaled to the global error handler via RxJavaPlugins.

Nonetheless, let’s see what each notable point does: But what if we don’t know the number of students and we don’t really want to stop the evaluation in case of an error. A worse scenario is that both onXXX methods may run at vreate same time which violates the sequential protocol of Completable.

Subscribes a given CompletableObserver subclass to this Completable and returns the given CompletableObserver as is. Kotlin has no checked exceptions ; Update 2 There is also fromAction factory method for creating Completable. Suppose we update any User model compleetable the app and want to just notify the server about it. I’ll post an creatte series about RxJava 2. Returns an Observable which first delivers the events of the other Observable then runs this CompletableConsumable.

If this Completable terminates with an onErrorthe exception is dropped and downstream receives just onCompleted. Dealing with exceptions Completable.

Clearer RxJava intentions with Single and Completable

For each new Completable student, first we increment the wip count and then subscribe the evaluator to it. Unsurprisingly, many of them match their counterpart in Observablehowever, a lot of them is missing because they don’t make sense in a valueless stream.

Returns a Maybe which will subscribe to this Completable and once that is completed then will subscribe to the next MaybeSource. Returns a Completable that first runs this Completable and then the other completable. It is practically a named alias of an Action1 parametrized by the CompletableSubscriber.


Single is an Observable which only emits one item or throws an error. Completble Archive About Submit your article. This is an interesting optimization in the Completable and in Reactive-Streams world and it does technically work: I have written a simple factory for wrapping a Runnable object into an Observable: By using Completable we agree to ignore the onNext event and only handle onComplete and onError. Hides the identity of this Completable and its Disposable.

Its usage pattern greatly resembles the use of Observable or Single with the difference that it doesn’t deal with values at all but only with the terminal events and as such, many operators are meaningless for Completable.

Since the Creae API features no values but only the terminal onError and onCompleted events, there are a way less meaningful operators possible unlike the main Observable class; therefore, most of the examples will feature an existing Completable operator. Sometimes I want to trigger a Runnable as part of my Observable sequence, but the Runnable does not report progress. For convenience, the subscribeWith CompletableObserver method is provided as well to allow working with a CompletableObserver or subclass fompletable to be applied with in a fluent manner such as in the example above.

Note that misbehaving Completable sources can disrupt this and trigger early completion if they send multiple terminal events.