java.lang.Object | |
↳ | io.reactivex.Completable |
![]() |
Represents a deferred computation without any value but only indication for completion or exception. The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Completable() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static Completable |
amb(Iterable<? extends CompletableSource> sources)
Returns a Completable which terminates as soon as one of the source Completables
terminates (normally or with an error) and cancels all other Completables.
| ||||||||||
static Completable |
ambArray(CompletableSource... sources)
Returns a Completable which terminates as soon as one of the source Completables
terminates (normally or with an error) and cancels all other Completables.
| ||||||||||
final Completable |
ambWith(CompletableSource other)
Returns a Completable that emits the a terminated event of either this Completable
or the other Completable whichever fires first.
| ||||||||||
final <T> Maybe<T> |
andThen(MaybeSource<T> next)
Returns a
Maybe which will subscribe to this Completable and once that is completed then
will subscribe to the next MaybeSource. | ||||||||||
final <T> Flowable<T> |
andThen(Publisher<T> next)
Returns a Flowable which will subscribe to this Completable and once that is completed then
will subscribe to the
next Flowable. | ||||||||||
final <T> Single<T> |
andThen(SingleSource<T> next)
Returns a Single which will subscribe to this Completable and once that is completed then
will subscribe to the
next SingleSource. | ||||||||||
final <T> Observable<T> |
andThen(ObservableSource<T> next)
Returns an Observable which will subscribe to this Completable and once that is completed then
will subscribe to the
next ObservableSource. | ||||||||||
final Completable |
andThen(CompletableSource next)
Returns a Completable that first runs this Completable
and then the other completable.
| ||||||||||
final void |
blockingAwait()
Subscribes to and awaits the termination of this Completable instance in a blocking manner and
rethrows any exception emitted.
| ||||||||||
final boolean |
blockingAwait(long timeout, TimeUnit unit)
Subscribes to and awaits the termination of this Completable instance in a blocking manner
with a specific timeout and rethrows any exception emitted within the timeout window.
| ||||||||||
final Throwable |
blockingGet()
Subscribes to this Completable instance and blocks until it terminates, then returns null or
the emitted exception if any.
| ||||||||||
final Throwable |
blockingGet(long timeout, TimeUnit unit)
Subscribes to this Completable instance and blocks until it terminates or the specified timeout
elapses, then returns null for normal termination or the emitted exception if any.
| ||||||||||
final Completable |
cache()
Subscribes to this Completable only once, when the first CompletableObserver
subscribes to the result Completable, caches its terminal event
and relays/replays it to observers.
| ||||||||||
static Completable |
complete()
Returns a Completable instance that completes immediately when subscribed to.
| ||||||||||
final Completable |
compose(CompletableTransformer transformer)
Calls the given transformer function with this instance and returns the function's resulting
Completable.
| ||||||||||
static Completable |
concat(Publisher<? extends CompletableSource> sources)
Returns a Completable which completes only when all sources complete, one after another.
| ||||||||||
static Completable |
concat(Iterable<? extends CompletableSource> sources)
Returns a Completable which completes only when all sources complete, one after another.
| ||||||||||
static Completable |
concat(Publisher<? extends CompletableSource> sources, int prefetch)
Returns a Completable which completes only when all sources complete, one after another.
| ||||||||||
static Completable |
concatArray(CompletableSource... sources)
Returns a Completable which completes only when all sources complete, one after another.
| ||||||||||
final Completable |
concatWith(CompletableSource other)
Concatenates this Completable with another Completable.
| ||||||||||
static Completable |
create(CompletableOnSubscribe source)
Provides an API (via a cold Completable) that bridges the reactive world with the callback-style world.
| ||||||||||
static Completable |
defer(Callable<? extends CompletableSource> completableSupplier)
Defers the subscription to a Completable instance returned by a supplier.
| ||||||||||
final Completable |
delay(long delay, TimeUnit unit, Scheduler scheduler, boolean delayError)
Returns a Completable which delays the emission of the completion event, and optionally the error as well, by the given time while
running on the specified scheduler.
| ||||||||||
final Completable |
delay(long delay, TimeUnit unit)
Returns a Completable which delays the emission of the completion event by the given time.
| ||||||||||
final Completable |
delay(long delay, TimeUnit unit, Scheduler scheduler)
Returns a Completable which delays the emission of the completion event by the given time while
running on the specified scheduler.
| ||||||||||
final Completable |
doAfterTerminate(Action onAfterTerminate)
Returns a Completable instance that calls the given onTerminate callback after this Completable
completes normally or with an exception
| ||||||||||
final Completable |
doFinally(Action onFinally)
Calls the specified action after this Completable signals onError or onComplete or gets disposed by
the downstream.
| ||||||||||
final Completable |
doOnComplete(Action onComplete)
Returns a Completable which calls the given onComplete callback if this Completable completes.
| ||||||||||
final Completable |
doOnDispose(Action onDispose)
Calls the shared
Action if a CompletableObserver subscribed to the current
Completable disposes the common Disposable it received via onSubscribe. | ||||||||||
final Completable |
doOnError(Consumer<? super Throwable> onError)
Returns a Completable which calls the given onError callback if this Completable emits an error.
| ||||||||||
final Completable |
doOnEvent(Consumer<? super Throwable> onEvent)
Returns a Completable which calls the given onEvent callback with the (throwable) for an onError
or (null) for an onComplete signal from this Completable before delivering said signal to the downstream.
| ||||||||||
final Completable |
doOnSubscribe(Consumer<? super Disposable> onSubscribe)
Returns a Completable instance that calls the given onSubscribe callback with the disposable
that child subscribers receive on subscription.
| ||||||||||
final Completable |
doOnTerminate(Action onTerminate)
Returns a Completable instance that calls the given onTerminate callback just before this Completable
completes normally or with an exception
| ||||||||||
static Completable |
error(Throwable error)
Creates a Completable instance that emits the given Throwable exception to subscribers.
| ||||||||||
static Completable |
error(Callable<? extends Throwable> errorSupplier)
Creates a Completable which calls the given error supplier for each subscriber
and emits its returned Throwable.
| ||||||||||
static Completable |
fromAction(Action run)
Returns a Completable instance that runs the given Action for each subscriber and
emits either an unchecked exception or simply completes.
| ||||||||||
static Completable |
fromCallable(Callable<?> callable)
Returns a Completable which when subscribed, executes the callable function, ignores its
normal result and emits onError or onComplete only.
| ||||||||||
static Completable |
fromFuture(Future<?> future)
Returns a Completable instance that reacts to the termination of the given Future in a blocking fashion.
| ||||||||||
static <T> Completable |
fromObservable(ObservableSource<T> observable)
Returns a Completable instance that subscribes to the given Observable, ignores all values and
emits only the terminal event.
| ||||||||||
static <T> Completable |
fromPublisher(Publisher<T> publisher)
Returns a Completable instance that subscribes to the given publisher, ignores all values and
emits only the terminal event.
| ||||||||||
static Completable |
fromRunnable(Runnable run)
Returns a Completable instance that runs the given Runnable for each subscriber and
emits either its exception or simply completes.
| ||||||||||
static <T> Completable |
fromSingle(SingleSource<T> single)
Returns a Completable instance that when subscribed to, subscribes to the Single instance and
emits a completion event if the single emits onSuccess or forwards any onError events.
| ||||||||||
final Completable |
hide()
Hides the identity of this Completable and its Disposable.
| ||||||||||
final Completable |
lift(CompletableOperator onLift)
Advanced use without safeguards: lifts a CompletableOperator
transformation into the chain of Completables.
| ||||||||||
static Completable |
merge(Iterable<? extends CompletableSource> sources)
Returns a Completable instance that subscribes to all sources at once and
completes only when all source Completables complete or one of them emits an error.
| ||||||||||
static Completable |
merge(Publisher<? extends CompletableSource> sources, int maxConcurrency)
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.
| ||||||||||
static Completable |
merge(Publisher<? extends CompletableSource> sources)
Returns a Completable instance that subscribes to all sources at once and
completes only when all source Completables complete or one of them emits an error.
| ||||||||||
static Completable |
mergeArray(CompletableSource... sources)
Returns a Completable instance that subscribes to all sources at once and
completes only when all source Completables complete or one of them emits an error.
| ||||||||||
static Completable |
mergeArrayDelayError(CompletableSource... sources)
Returns a CompletableConsumable that subscribes to all Completables in the source array 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.
| ||||||||||
static Completable |
mergeDelayError(Publisher<? extends CompletableSource> sources)
Returns a Completable that subscribes to all Completables 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.
| ||||||||||
static Completable |
mergeDelayError(Iterable<? extends CompletableSource> sources)
Returns a Completable that subscribes to all Completables 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.
| ||||||||||
static Completable |
mergeDelayError(Publisher<? extends CompletableSource> sources, int maxConcurrency)
Returns a Completable that subscribes to a limited number 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.
| ||||||||||
final Completable |
mergeWith(CompletableSource other)
Returns a Completable which subscribes to this and the other Completable and completes
when both of them complete or one emits an error.
| ||||||||||
static Completable |
never()
Returns a Completable that never calls onError or onComplete.
| ||||||||||
final Completable |
observeOn(Scheduler scheduler)
Returns a Completable which emits the terminal events from the thread of the specified scheduler.
| ||||||||||
final Completable |
onErrorComplete(Predicate<? super Throwable> predicate)
Returns a Completable instance that if this Completable emits an error and the predicate returns
true, it will emit an onComplete and swallow the throwable.
| ||||||||||
final Completable |
onErrorComplete()
Returns a Completable instance that if this Completable emits an error, it will emit an onComplete
and swallow the throwable.
| ||||||||||
final Completable |
onErrorResumeNext(Function<? super Throwable, ? extends CompletableSource> errorMapper)
Returns a Completable instance that when encounters an error from this Completable, calls the
specified mapper function that returns another Completable instance for it and resumes the
execution with it.
| ||||||||||
final Completable |
repeat()
Returns a Completable that repeatedly subscribes to this Completable until cancelled.
| ||||||||||
final Completable |
repeat(long times)
Returns a Completable that subscribes repeatedly at most the given times to this Completable.
| ||||||||||
final Completable |
repeatUntil(BooleanSupplier stop)
Returns a Completable that repeatedly subscribes to this Completable so long as the given
stop supplier returns false.
| ||||||||||
final Completable |
repeatWhen(Function<? super Flowable<Object>, ? extends Publisher<?>> handler)
Returns a Completable instance that repeats when the Publisher returned by the handler
emits an item or completes when this Publisher emits a completed event.
| ||||||||||
final Completable |
retry(BiPredicate<? super Integer, ? super Throwable> predicate)
Returns a Completable that retries this Completable in case of an error as long as the predicate
returns true.
| ||||||||||
final Completable |
retry(Predicate<? super Throwable> predicate)
Returns a Completable that when this Completable emits an error, calls the given predicate with
the latest exception to decide whether to resubscribe to this or not.
| ||||||||||
final Completable |
retry()
Returns a Completable that retries this Completable as long as it emits an onError event.
| ||||||||||
final Completable |
retry(long times)
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.
| ||||||||||
final Completable |
retryWhen(Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler)
Returns a Completable which given a Publisher and when this Completable emits an error, delivers
that error through a Flowable and the Publisher should signal a value indicating a retry in response
or a terminal event indicating a termination.
| ||||||||||
final <T> Observable<T> |
startWith(Observable<T> other)
Returns an Observable which first delivers the events
of the other Observable then runs this CompletableConsumable.
| ||||||||||
final <T> Flowable<T> |
startWith(Publisher<T> other)
Returns a Flowable which first delivers the events
of the other Publisher then runs this Completable.
| ||||||||||
final Completable |
startWith(CompletableSource other)
Returns a Completable which first runs the other Completable
then this completable if the other completed normally.
| ||||||||||
final Disposable |
subscribe(Action onComplete, Consumer<? super Throwable> onError)
Subscribes to this Completable and calls back either the onError or onComplete functions.
| ||||||||||
final void |
subscribe(CompletableObserver s)
Subscribes the given CompletableObserver to this CompletableSource instance.
| ||||||||||
final Disposable |
subscribe()
Subscribes to this CompletableConsumable and returns a Disposable which can be used to cancel
the subscription.
| ||||||||||
final Disposable |
subscribe(Action onComplete)
Subscribes to this Completable and calls the given Action when this Completable
completes normally.
| ||||||||||
final Completable |
subscribeOn(Scheduler scheduler)
Returns a Completable which subscribes the child subscriber on the specified scheduler, making
sure the subscription side-effects happen on that specific thread of the scheduler.
| ||||||||||
final <E extends CompletableObserver> E |
subscribeWith(E observer)
Subscribes a given CompletableObserver (subclass) to this Completable and returns the given
CompletableObserver as is.
| ||||||||||
final TestObserver<Void> |
test()
Creates a TestObserver and subscribes
it to this Completable.
| ||||||||||
final TestObserver<Void> |
test(boolean cancelled)
Creates a TestObserver optionally in cancelled state, then subscribes it to this Completable.
| ||||||||||
final Completable |
timeout(long timeout, TimeUnit unit, Scheduler scheduler, CompletableSource other)
Returns a Completable that runs this Completable and switches to the other Completable
in case this Completable doesn't complete within the given time while "waiting" on
the specified scheduler.
| ||||||||||
final Completable |
timeout(long timeout, TimeUnit unit, CompletableSource other)
Returns a Completable that runs this Completable and switches to the other Completable
in case this Completable doesn't complete within the given time.
| ||||||||||
final Completable |
timeout(long timeout, TimeUnit unit)
Returns a Completable that runs this Completable and emits a TimeoutException in case
this Completable doesn't complete within the given time.
| ||||||||||
final Completable |
timeout(long timeout, TimeUnit unit, Scheduler scheduler)
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.
| ||||||||||
static Completable |
timer(long delay, TimeUnit unit)
Returns a Completable instance that fires its onComplete event after the given delay elapsed.
| ||||||||||
static Completable |
timer(long delay, TimeUnit unit, Scheduler scheduler)
Returns a Completable instance that fires its onComplete event after the given delay elapsed
by using the supplied scheduler.
| ||||||||||
final <U> U |
to(Function<? super Completable, U> converter)
Allows fluent conversion to another type via a function callback.
| ||||||||||
final <T> Flowable<T> |
toFlowable()
Returns a Flowable which when subscribed to subscribes to this Completable and
relays the terminal events to the subscriber.
| ||||||||||
final <T> Maybe<T> |
toMaybe()
Converts this Completable into a
Maybe . | ||||||||||
final <T> Observable<T> |
toObservable()
Returns an Observable which when subscribed to subscribes to this Completable and
relays the terminal events to the subscriber.
| ||||||||||
final <T> Single<T> |
toSingle(Callable<? extends T> completionValueSupplier)
Converts this Completable into a Single which when this Completable completes normally,
calls the given supplier and emits its returned value through onSuccess.
| ||||||||||
final <T> Single<T> |
toSingleDefault(T completionValue)
Converts this Completable into a Single which when this Completable completes normally,
emits the given value through onSuccess.
| ||||||||||
static Completable |
unsafeCreate(CompletableSource source)
Constructs a Completable instance by wrapping the given source callback
without any safeguards; you should manage the lifecycle and response
to downstream cancellation/dispose.
| ||||||||||
final Completable |
unsubscribeOn(Scheduler scheduler)
Returns a Completable which makes sure when a subscriber cancels the subscription, the
dispose is called on the specified scheduler
| ||||||||||
static <R> Completable |
using(Callable<R> resourceSupplier, Function<? super R, ? extends CompletableSource> completableFunction, Consumer<? super R> disposer, boolean eager)
Returns a Completable instance which manages a resource along
with a custom Completable instance while the subscription is active and performs eager or lazy
resource disposition.
| ||||||||||
static <R> Completable |
using(Callable<R> resourceSupplier, Function<? super R, ? extends CompletableSource> completableFunction, Consumer<? super R> disposer)
Returns a Completable instance which manages a resource along
with a custom Completable instance while the subscription is active.
| ||||||||||
static Completable |
wrap(CompletableSource source)
Wraps the given CompletableSource into a Completable
if not already Completable.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void |
subscribeActual(CompletableObserver s)
Implement this to handle the incoming CompletableObserver and
perform the business logic in your operator.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Returns a Completable which terminates as soon as one of the source Completables terminates (normally or with an error) and cancels all other Completables.
amb
does not operate by default on a particular Scheduler
.sources | the array of source Completables. A subscription to each source will occur in the same order as in this Iterable. |
---|
NullPointerException | if sources is null |
---|
Returns a Completable which terminates as soon as one of the source Completables terminates (normally or with an error) and cancels all other Completables.
ambArray
does not operate by default on a particular Scheduler
.sources | the array of source Completables. A subscription to each source will occur in the same order as in this array. |
---|
NullPointerException | if sources is null |
---|
Returns a Completable that emits the a terminated event of either this Completable or the other Completable whichever fires first.
ambWith
does not operate by default on a particular Scheduler
.other | the other Completable, not null. A subscription to this provided source will occur after subscribing to the current source. |
---|
NullPointerException | if other is null |
---|
Returns a Maybe
which will subscribe to this Completable and once that is completed then
will subscribe to the next
MaybeSource. An error event from this Completable will be
propagated to the downstream subscriber and will result in skipping the subscription of the
Maybe.
andThen
does not operate by default on a particular Scheduler
.next | the Maybe to subscribe after this Completable is completed, not null |
---|
Returns a Flowable which will subscribe to this Completable and once that is completed then
will subscribe to the next
Flowable. An error event from this Completable will be
propagated to the downstream subscriber and will result in skipping the subscription of the
Publisher.
Flowable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.andThen
does not operate by default on a particular Scheduler
.next | the Publisher to subscribe after this Completable is completed, not null |
---|
NullPointerException | if next is null |
---|
Returns a Single which will subscribe to this Completable and once that is completed then
will subscribe to the next
SingleSource. An error event from this Completable will be
propagated to the downstream subscriber and will result in skipping the subscription of the
Single.
andThen
does not operate by default on a particular Scheduler
.next | the Single to subscribe after this Completable is completed, not null |
---|
Returns an Observable which will subscribe to this Completable and once that is completed then
will subscribe to the next
ObservableSource. An error event from this Completable will be
propagated to the downstream subscriber and will result in skipping the subscription of the
Observable.
andThen
does not operate by default on a particular Scheduler
.next | the Observable to subscribe after this Completable is completed, not null |
---|
NullPointerException | if next is null |
---|
Returns a Completable that first runs this Completable and then the other completable.
This is an alias for concatWith(CompletableSource)
.
andThen
does not operate by default on a particular Scheduler
.next | the other Completable, not null |
---|
NullPointerException | if other is null |
---|
Subscribes to and awaits the termination of this Completable instance in a blocking manner and rethrows any exception emitted.
blockingAwait
does not operate by default on a particular Scheduler
.RuntimeException | wrapping an InterruptedException if the current thread is interrupted |
---|
Subscribes to and awaits the termination of this Completable instance in a blocking manner with a specific timeout and rethrows any exception emitted within the timeout window.
blockingAwait
does not operate by default on a particular Scheduler
.timeout | the timeout value |
---|---|
unit | the timeout unit |
RuntimeException | wrapping an InterruptedException if the current thread is interrupted |
---|
Subscribes to this Completable instance and blocks until it terminates, then returns null or the emitted exception if any.
blockingGet
does not operate by default on a particular Scheduler
.RuntimeException | that wraps an InterruptedException if the wait is interrupted |
---|
Subscribes to this Completable instance and blocks until it terminates or the specified timeout elapses, then returns null for normal termination or the emitted exception if any.
blockingGet
does not operate by default on a particular Scheduler
.timeout | the timeout value |
---|---|
unit | the time unit |
RuntimeException | that wraps an InterruptedException if the wait is interrupted or TimeoutException if the specified timeout elapsed before it |
---|
Subscribes to this Completable only once, when the first CompletableObserver subscribes to the result Completable, caches its terminal event and relays/replays it to observers.
Note that this operator doesn't allow disposing the connection of the upstream source.
cache
does not operate by default on a particular Scheduler
.History: 2.0.4 - experimental
Returns a Completable instance that completes immediately when subscribed to.
complete
does not operate by default on a particular Scheduler
.Calls the given transformer function with this instance and returns the function's resulting Completable.
compose
does not operate by default on a particular Scheduler
.transformer | the transformer function, not null |
---|
NullPointerException | if transformer is null |
---|
Returns a Completable which completes only when all sources complete, one after another.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.concat
does not operate by default on a particular Scheduler
.sources | the sources to concatenate |
---|
NullPointerException | if sources is null |
---|
Returns a Completable which completes only when all sources complete, one after another.
concat
does not operate by default on a particular Scheduler
.sources | the sources to concatenate |
---|
NullPointerException | if sources is null |
---|
Returns a Completable which completes only when all sources complete, one after another.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.concat
does not operate by default on a particular Scheduler
.sources | the sources to concatenate |
---|---|
prefetch | the number of sources to prefetch from the sources |
NullPointerException | if sources is null |
---|
Returns a Completable which completes only when all sources complete, one after another.
concatArray
does not operate by default on a particular Scheduler
.sources | the sources to concatenate |
---|
NullPointerException | if sources is null |
---|
Concatenates this Completable with another Completable.
concatWith
does not operate by default on a particular Scheduler
.other | the other Completable, not null |
---|
NullPointerException | if other is null |
---|
Provides an API (via a cold Completable) that bridges the reactive world with the callback-style world.
Example:
Completable.create(emitter -> {
Callback listener = new Callback() {
@Override
public void onEvent(Event e) {
emitter.onComplete();
}
@Override
public void onFailure(Exception e) {
emitter.onError(e);
}
};
AutoCloseable c = api.someMethod(listener);
emitter.setCancellable(c::close);
});
create
does not operate by default on a particular Scheduler
.source | the emitter that is called when a CompletableObserver subscribes to the returned Completable |
---|
Defers the subscription to a Completable instance returned by a supplier.
defer
does not operate by default on a particular Scheduler
.completableSupplier | the supplier that returns the Completable that will be subscribed to. |
---|
Returns a Completable which delays the emission of the completion event, and optionally the error as well, by the given time while running on the specified scheduler.
delay
operates on the Scheduler
you specify.delay | the delay time |
---|---|
unit | the delay unit |
scheduler | the scheduler to run the delayed completion on |
delayError | delay the error emission as well? |
NullPointerException | if unit or scheduler is null |
---|
Returns a Completable which delays the emission of the completion event by the given time.
delay
does operate by default on the computation
Scheduler
.delay | the delay time |
---|---|
unit | the delay unit |
NullPointerException | if unit is null |
---|
Returns a Completable which delays the emission of the completion event by the given time while running on the specified scheduler.
delay
operates on the Scheduler
you specify.delay | the delay time |
---|---|
unit | the delay unit |
scheduler | the scheduler to run the delayed completion on |
NullPointerException | if unit or scheduler is null |
---|
Returns a Completable instance that calls the given onTerminate callback after this Completable completes normally or with an exception
doAfterTerminate
does not operate by default on a particular Scheduler
.onAfterTerminate | the callback to call after this Completable terminates |
---|
Calls the specified action after this Completable signals onError or onComplete or gets disposed by the downstream.
In case of a race between a terminal event and a dispose call, the provided onFinally
action
is executed once per subscription.
Note that the onFinally
action is shared between subscriptions and as such
should be thread-safe.
doFinally
does not operate by default on a particular Scheduler
.History: 2.0.1 - experimental
onFinally | the action called when this Completable terminates or gets cancelled |
---|
Returns a Completable which calls the given onComplete callback if this Completable completes.
doOnComplete
does not operate by default on a particular Scheduler
.onComplete | the callback to call when this emits an onComplete event |
---|
NullPointerException | if onComplete is null |
---|
Calls the shared Action
if a CompletableObserver subscribed to the current
Completable disposes the common Disposable it received via onSubscribe.
doOnDispose
does not operate by default on a particular Scheduler
.onDispose | the action to call when the child subscriber disposes the subscription |
---|
NullPointerException | if onDispose is null |
---|
Returns a Completable which calls the given onError callback if this Completable emits an error.
doOnError
does not operate by default on a particular Scheduler
.onError | the error callback |
---|
NullPointerException | if onError is null |
---|
Returns a Completable which calls the given onEvent callback with the (throwable) for an onError or (null) for an onComplete signal from this Completable before delivering said signal to the downstream.
doOnEvent
does not operate by default on a particular Scheduler
.onEvent | the event callback |
---|
NullPointerException | if onEvent is null |
---|
Returns a Completable instance that calls the given onSubscribe callback with the disposable that child subscribers receive on subscription.
doOnSubscribe
does not operate by default on a particular Scheduler
.onSubscribe | the callback called when a child subscriber subscribes |
---|
NullPointerException | if onSubscribe is null |
---|
Returns a Completable instance that calls the given onTerminate callback just before this Completable completes normally or with an exception
doOnTerminate
does not operate by default on a particular Scheduler
.onTerminate | the callback to call just before this Completable terminates |
---|
Creates a Completable instance that emits the given Throwable exception to subscribers.
error
does not operate by default on a particular Scheduler
.error | the Throwable instance to emit, not null |
---|
NullPointerException | if error is null |
---|
Creates a Completable which calls the given error supplier for each subscriber and emits its returned Throwable.
If the errorSupplier returns null, the child CompletableObservers will receive a NullPointerException.
error
does not operate by default on a particular Scheduler
.errorSupplier | the error supplier, not null |
---|
NullPointerException | if errorSupplier is null |
---|
Returns a Completable instance that runs the given Action for each subscriber and emits either an unchecked exception or simply completes.
fromAction
does not operate by default on a particular Scheduler
.run | the runnable to run for each subscriber |
---|
NullPointerException | if run is null |
---|
Returns a Completable which when subscribed, executes the callable function, ignores its normal result and emits onError or onComplete only.
fromCallable
does not operate by default on a particular Scheduler
.callable | the callable instance to execute for each subscriber |
---|
Returns a Completable instance that reacts to the termination of the given Future in a blocking fashion.
Note that cancellation from any of the subscribers to this Completable will cancel the future.
fromFuture
does not operate by default on a particular Scheduler
.future | the future to react to |
---|
Returns a Completable instance that subscribes to the given Observable, ignores all values and emits only the terminal event.
fromObservable
does not operate by default on a particular Scheduler
.observable | the Observable instance to subscribe to, not null |
---|
NullPointerException | if flowable is null |
---|
Returns a Completable instance that subscribes to the given publisher, ignores all values and emits only the terminal event.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.fromPublisher
does not operate by default on a particular Scheduler
.publisher | the Publisher instance to subscribe to, not null |
---|
NullPointerException | if publisher is null |
---|
Returns a Completable instance that runs the given Runnable for each subscriber and emits either its exception or simply completes.
fromRunnable
does not operate by default on a particular Scheduler
.run | the runnable to run for each subscriber |
---|
NullPointerException | if run is null |
---|
Returns a Completable instance that when subscribed to, subscribes to the Single instance and emits a completion event if the single emits onSuccess or forwards any onError events.
fromSingle
does not operate by default on a particular Scheduler
.single | the Single instance to subscribe to, not null |
---|
NullPointerException | if single is null |
---|
Hides the identity of this Completable and its Disposable.
Allows preventing certain identity-based optimizations (fusion).
hide
does not operate by default on a particular Scheduler
.History: 2.0.5 - experimental
Advanced use without safeguards: lifts a CompletableOperator transformation into the chain of Completables.
lift
does not operate by default on a particular Scheduler
.onLift | the lifting function that transforms the child subscriber with a parent subscriber. |
---|
NullPointerException | if onLift is null |
---|
Returns a Completable instance that subscribes to all sources at once and completes only when all source Completables complete or one of them emits an error.
merge
does not operate by default on a particular Scheduler
.sources | the iterable sequence of sources. |
---|
NullPointerException | if sources is null |
---|
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.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.merge
does not operate by default on a particular Scheduler
.sources | the iterable sequence of sources. |
---|---|
maxConcurrency | the maximum number of concurrent subscriptions |
NullPointerException | if sources is null |
---|---|
IllegalArgumentException | if maxConcurrency is less than 1 |
Returns a Completable instance that subscribes to all sources at once and completes only when all source Completables complete or one of them emits an error.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.merge
does not operate by default on a particular Scheduler
.sources | the iterable sequence of sources. |
---|
NullPointerException | if sources is null |
---|
Returns a Completable instance that subscribes to all sources at once and completes only when all source Completables complete or one of them emits an error.
mergeArray
does not operate by default on a particular Scheduler
.sources | the iterable sequence of sources. |
---|
NullPointerException | if sources is null |
---|
Returns a CompletableConsumable that subscribes to all Completables in the source array 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.
mergeArrayDelayError
does not operate by default on a particular Scheduler
.sources | the array of Completables |
---|
NullPointerException | if sources is null |
---|
Returns a Completable that subscribes to all Completables 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.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.mergeDelayError
does not operate by default on a particular Scheduler
.sources | the sequence of Completables |
---|
NullPointerException | if sources is null |
---|
Returns a Completable that subscribes to all Completables 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.
mergeDelayError
does not operate by default on a particular Scheduler
.sources | the sequence of Completables |
---|
NullPointerException | if sources is null |
---|
Returns a Completable that subscribes to a limited number 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.
Completable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.mergeDelayError
does not operate by default on a particular Scheduler
.sources | the sequence of Completables |
---|---|
maxConcurrency | the maximum number of concurrent subscriptions to Completables |
NullPointerException | if sources is null |
---|
Returns a Completable which subscribes to this and the other Completable and completes when both of them complete or one emits an error.
mergeWith
does not operate by default on a particular Scheduler
.other | the other Completable instance |
---|
NullPointerException | if other is null |
---|
Returns a Completable that never calls onError or onComplete.
never
does not operate by default on a particular Scheduler
.Returns a Completable which emits the terminal events from the thread of the specified scheduler.
observeOn
operates on a Scheduler
you specify.scheduler | the scheduler to emit terminal events on |
---|
NullPointerException | if scheduler is null |
---|
Returns a Completable instance that if this Completable emits an error and the predicate returns true, it will emit an onComplete and swallow the throwable.
onErrorComplete
does not operate by default on a particular Scheduler
.predicate | the predicate to call when an Throwable is emitted which should return true if the Throwable should be swallowed and replaced with an onComplete. |
---|
Returns a Completable instance that if this Completable emits an error, it will emit an onComplete and swallow the throwable.
onErrorComplete
does not operate by default on a particular Scheduler
.Returns a Completable instance that when encounters an error from this Completable, calls the specified mapper function that returns another Completable instance for it and resumes the execution with it.
onErrorResumeNext
does not operate by default on a particular Scheduler
.errorMapper | the mapper function that takes the error and should return a Completable as continuation. |
---|
Returns a Completable that repeatedly subscribes to this Completable until cancelled.
repeat
does not operate by default on a particular Scheduler
.Returns a Completable that subscribes repeatedly at most the given times to this Completable.
repeat
does not operate by default on a particular Scheduler
.times | the number of times the resubscription should happen |
---|
IllegalArgumentException | if times is less than zero |
---|
Returns a Completable that repeatedly subscribes to this Completable so long as the given stop supplier returns false.
repeatUntil
does not operate by default on a particular Scheduler
.stop | the supplier that should return true to stop resubscribing. |
---|
NullPointerException | if stop is null |
---|
Returns a Completable instance that repeats when the Publisher returned by the handler emits an item or completes when this Publisher emits a completed event.
repeatWhen
does not operate by default on a particular Scheduler
.handler | the function that transforms the stream of values indicating the completion of this Completable and returns a Publisher that emits items for repeating or completes to indicate the repetition should stop |
---|
NullPointerException | if stop is null |
---|
Returns a Completable that retries this Completable in case of an error as long as the predicate returns true.
retry
does not operate by default on a particular Scheduler
.predicate | the predicate called when this emits an error with the repeat count and the latest exception and should return true to retry. |
---|
Returns a Completable that when this Completable emits an error, calls the given predicate with the latest exception to decide whether to resubscribe to this or not.
retry
does not operate by default on a particular Scheduler
.predicate | the predicate that is called with the latest throwable and should return true to indicate the returned Completable should resubscribe to this Completable. |
---|
NullPointerException | if predicate is null |
---|
Returns a Completable that retries this Completable as long as it emits an onError event.
retry
does not operate by default on a particular Scheduler
.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.
retry
does not operate by default on a particular Scheduler
.times | the number of times the returned Completable should retry this Completable |
---|
IllegalArgumentException | if times is negative |
---|
Returns a Completable which given a Publisher and when this Completable emits an error, delivers that error through a Flowable and the Publisher should signal a value indicating a retry in response or a terminal event indicating a termination.
retryWhen
does not operate by default on a particular Scheduler
.handler | the handler that receives a Flowable delivering Throwables and should return a Publisher that emits items to indicate retries or emits terminal events to indicate termination. |
---|
NullPointerException | if handler is null |
---|
Returns an Observable which first delivers the events of the other Observable then runs this CompletableConsumable.
startWith
does not operate by default on a particular Scheduler
.other | the other Observable to run first |
---|
NullPointerException | if other is null |
---|
Returns a Flowable which first delivers the events of the other Publisher then runs this Completable.
Flowable
honors the backpressure of the downstream consumer
and expects the other Publisher
to honor it as well.startWith
does not operate by default on a particular Scheduler
.other | the other Publisher to run first |
---|
NullPointerException | if other is null |
---|
Returns a Completable which first runs the other Completable then this completable if the other completed normally.
startWith
does not operate by default on a particular Scheduler
.other | the other completable to run first |
---|
NullPointerException | if other is null |
---|
Subscribes to this Completable and calls back either the onError or onComplete functions.
subscribe
does not operate by default on a particular Scheduler
.onComplete | the runnable that is called if the Completable completes normally |
---|---|
onError | the consumer that is called if this Completable emits an error |
NullPointerException | if either callback is null |
---|
Subscribes the given CompletableObserver to this CompletableSource instance.
s | the CompletableObserver, not null |
---|
Subscribes to this CompletableConsumable and returns a Disposable which can be used to cancel the subscription.
subscribe
does not operate by default on a particular Scheduler
.Subscribes to this Completable and calls the given Action when this Completable completes normally.
If the Completable emits an error, it is wrapped into an
OnErrorNotImplementedException
and routed to the RxJavaPlugins.onError handler.
subscribe
does not operate by default on a particular Scheduler
.onComplete | the runnable called when this Completable completes normally |
---|
Returns a Completable which subscribes the child subscriber on the specified scheduler, making sure the subscription side-effects happen on that specific thread of the scheduler.
subscribeOn
operates on a Scheduler
you specify.scheduler | the Scheduler to subscribe on |
---|
NullPointerException | if scheduler is null |
---|
Subscribes a given CompletableObserver (subclass) to this Completable and returns the given CompletableObserver as is.
Usage example:
Completable source = Completable.complete().delay(1, TimeUnit.SECONDS);
CompositeDisposable composite = new CompositeDisposable();
class ResourceCompletableObserver implements CompletableObserver, Disposable {
// ...
}
composite.add(source.subscribeWith(new ResourceCompletableObserver()));
subscribeWith
does not operate by default on a particular Scheduler
.observer | the CompletableObserver (subclass) to use and return, not null |
---|
observer
NullPointerException | if observer is null |
---|
Creates a TestObserver and subscribes it to this Completable.
test
does not operate by default on a particular Scheduler
.Creates a TestObserver optionally in cancelled state, then subscribes it to this Completable.
cancelled | if true, the TestObserver will be cancelled before subscribing to this
Completable.
|
---|
Returns a Completable that runs this Completable and switches to the other Completable in case this Completable doesn't complete within the given time while "waiting" on the specified scheduler.
timeout
subscribes to the other CompletableSource on
the Scheduler
you specify.timeout | the timeout value |
---|---|
unit | the timeout unit |
scheduler | the scheduler to use to wait for completion |
other | the other Completable instance to switch to in case of a timeout |
NullPointerException | if unit, scheduler or other is null |
---|
Returns a Completable that runs this Completable and switches to the other Completable in case this Completable doesn't complete within the given time.
timeout
subscribes to the other CompletableSource on
the computation
Scheduler
.timeout | the timeout value |
---|---|
unit | the timeout unit |
other | the other Completable instance to switch to in case of a timeout |
NullPointerException | if unit or other is null |
---|
Returns a Completable that runs this Completable and emits a TimeoutException in case this Completable doesn't complete within the given time.
timeout
signals the TimeoutException on the computation
Scheduler
.timeout | the timeout value |
---|---|
unit | the timeout unit |
NullPointerException | if unit is null |
---|
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.
timeout
signals the TimeoutException on the Scheduler
you specify.timeout | the timeout value |
---|---|
unit | the timeout unit |
scheduler | the scheduler to use to wait for completion |
NullPointerException | if unit or scheduler is null |
---|
Returns a Completable instance that fires its onComplete event after the given delay elapsed.
timer
does operate by default on the computation
Scheduler
.delay | the delay time |
---|---|
unit | the delay unit |
Returns a Completable instance that fires its onComplete event after the given delay elapsed by using the supplied scheduler.
timer
operates on the Scheduler
you specify.delay | the delay time |
---|---|
unit | the delay unit |
scheduler | the scheduler where to emit the complete event |
Allows fluent conversion to another type via a function callback.
to
does not operate by default on a particular Scheduler
.converter | the function called with this which should return some other value. |
---|
NullPointerException | if converter is null |
---|
Returns a Flowable which when subscribed to subscribes to this Completable and relays the terminal events to the subscriber.
Flowable
honors the backpressure of the downstream consumer.toFlowable
does not operate by default on a particular Scheduler
.Returns an Observable which when subscribed to subscribes to this Completable and relays the terminal events to the subscriber.
toObservable
does not operate by default on a particular Scheduler
.Converts this Completable into a Single which when this Completable completes normally, calls the given supplier and emits its returned value through onSuccess.
toSingle
does not operate by default on a particular Scheduler
.completionValueSupplier | the value supplier called when this Completable completes normally |
---|
NullPointerException | if completionValueSupplier is null |
---|
Converts this Completable into a Single which when this Completable completes normally, emits the given value through onSuccess.
toSingleDefault
does not operate by default on a particular Scheduler
.completionValue | the value to emit when this Completable completes normally |
---|
NullPointerException | if completionValue is null |
---|
Constructs a Completable instance by wrapping the given source callback without any safeguards; you should manage the lifecycle and response to downstream cancellation/dispose.
unsafeCreate
does not operate by default on a particular Scheduler
.source | the callback which will receive the CompletableObserver instances when the Completable is subscribed to. |
---|
NullPointerException | if source is null |
---|
Returns a Completable which makes sure when a subscriber cancels the subscription, the dispose is called on the specified scheduler
unsubscribeOn
calls dispose() of the upstream on the Scheduler
you specify.scheduler | the target scheduler where to execute the cancellation |
---|
NullPointerException | if scheduler is null |
---|
Returns a Completable instance which manages a resource along with a custom Completable instance while the subscription is active and performs eager or lazy resource disposition.
If this overload performs a lazy cancellation after the terminal event is emitted. Exceptions thrown at this time will be delivered to RxJavaPlugins only.
using
does not operate by default on a particular Scheduler
.resourceSupplier | the supplier that returns a resource to be managed |
---|---|
completableFunction | the function that given a resource returns a non-null Completable instance that will be subscribed to |
disposer | the consumer that disposes the resource created by the resource supplier |
eager | if true, the resource is disposed before the terminal event is emitted, if false, the resource is disposed after the terminal event has been emitted |
Returns a Completable instance which manages a resource along with a custom Completable instance while the subscription is active.
This overload disposes eagerly before the terminal event is emitted.
using
does not operate by default on a particular Scheduler
.resourceSupplier | the supplier that returns a resource to be managed. |
---|---|
completableFunction | the function that given a resource returns a Completable instance that will be subscribed to |
disposer | the consumer that disposes the resource created by the resource supplier |
Wraps the given CompletableSource into a Completable if not already Completable.
wrap
does not operate by default on a particular Scheduler
.source | the source to wrap |
---|
NullPointerException | if source is null |
---|
Implement this to handle the incoming CompletableObserver and perform the business logic in your operator.
s | the CompletableObserver instance, never null |
---|