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: Meshura Zubei
Country: Trinidad & Tobago
Language: English (Spanish)
Genre: Education
Published (Last): 20 July 2008
Pages: 319
PDF File Size: 19.66 Mb
ePub File Size: 8.59 Mb
ISBN: 131-9-72847-629-2
Downloads: 65111
Price: Free* [*Free Regsitration Required]
Uploader: Faenos

If the Callable throws an exception, the respective Throwable is delivered to the downstream via CompletableObserver. Returns a Completable which emits the terminal events from the thread of the specified scheduler.

Handling the onXXX notifications isn’t that complicated either: Returns a Maybe which will subscribe to this Completable and once cdeate is completed then will subscribe to the next MaybeSource. The supplied predicate will receive the exception and should return true if the exception should be dropped and replaced by a onCompleted event.

Clearer RxJava intentions with Single and Completable

Subscribera mandatory and maybe shared SubscriptionList container is created to support resource association with any Subscriber instance.

Completable is only concerned with execution completion whether the task has reach to completion or some error has occurred. By clicking “Post Cpmpletable Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyxompletable that your continued use of the website is subject to these policies. Note that if you hold the clap button, you comp,etable leave more claps! Returns a Completable that runs this Completable and emits a TimeoutException in case this Completable doesn’t complete within the given time while “waiting” on the specified Scheduler.

Subscriber saving on allocation cost, footprint and gives better performance overall. One of the most common use cases for RxJava in Android is for doing network calls.

Returns a Completable instance that keeps subscriptions to a limited number of sources at once and completes only when all source Completables complete or one of them emits an error.


Subscribes to and awaits the termination of this Completable instance in a blocking manner compleable a specific timeout and rethrows any exception emitted within the timeout window.

You can ignore the parameter this method or keep track all of the Subscription s in a composite. Returns a Completable instance that calls the given onTerminate callback just before this Completable completes normally or with an completabble. Otherwise, we can’t do much since the CompletableSubject could be subscribed to many Completable sources of which any can bring it to its terminal state. Returns a Completable which makes sure when a subscriber disposes the subscription, the dispose is called on the specified scheduler.

Constructs a Completable instance by wrapping the given source callback without any safeguards; you should manage the lifecycle and response to downstream disposal. Returns a Completable which delays the emission of the completion event by the given time while running on the specified scheduler.

If possible, use create CompletableOnSubscribe to create a source-like Completable instead. Creating an instance via a lambda expression is also straightforward but one has copmletable remember to call onSubscribe before calling the other onXXX methods.

Returns a Completable which calls the given onError callback if this Completable emits an error. Returns a Completable which terminates as soon as one of the source Completables terminates normally or with an error and disposes all other Completables. The second reason for the cretae order is that unsubscribing a Worker may cause unwanted interruptions down the line of onCompleted.

Home Archive About Submit your article. Returns a Completable which completes only when all sources complete, one after another. If the add returns falsethat means the CompletableSubject has reached its terminal state and reading the error field can tell how the child subscriber should be notified.

The following legend explains these diagrams: It features the usual onCompleted and onError but instead of complwtable Subscription and having an add method like rx. The CompletableSubscription will be used for tracking each CompletableSubscriber and help manage the unsubscription based on their identity.


Again, using a CompletableTransformer and extending the Completable is a better option as subscribeActual io. A worse scenario is that both onXXX methods may run at the same time which violates the sequential protocol of Creatw.

Subscribes to this Completable instance and blocks until it terminates, then returns null or the emitted exception if any. 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.

Completable (RxJava Javadoc )

Suppose we have only 1 student, after the subscribe loop, the wip will be 2, and after the only student finished, the wip will be 1, and we won’t notify the principal, right?

In addition, such operator can intercept the flow control calls of dispose and isDisposed that would have traveled upstream and perform additional actions depending on the same business logic requirements. Represents a computation without any value but only indication for completion or exception. Is there another option that catches any Throwable the Runnable might throw? Like an Observablea Completable is lazy, can be either “hot” or “cold”, synchronous or asynchronous. Calls the given transformer function with this creage and returns the function’s resulting Completable.

Regardless, what does it take to write such an operator for Completable? If this overload performs a lazy disposal after the terminal event is emitted.