public class Completable
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Completable.OnSubscribe
Callback used for building deferred computations that takes a CompletableSubscriber.
|
static interface |
Completable.Operator
Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
|
static interface |
Completable.Transformer
Convenience interface and callback used by the compose operator to turn a Completable into another
Completable fluently.
|
Modifier | Constructor and Description |
---|---|
protected |
Completable(Completable.OnSubscribe onSubscribe)
Constructs a Completable instance with the given onSubscribe callback.
|
protected |
Completable(Completable.OnSubscribe onSubscribe,
boolean useHook)
Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
hook.
|
Modifier and Type | Method and Description |
---|---|
static Completable |
amb(Completable... 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 |
amb(java.lang.Iterable<? extends Completable> 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.
|
Completable |
ambWith(Completable other)
Returns a Completable that emits the a terminated event of either this Completable
or the other Completable whichever fires first.
|
Completable |
andThen(Completable next)
Returns a completable that first runs this Completable
and then the other completable.
|
<T> Observable<T> |
andThen(Observable<T> next)
Returns an Observable which will subscribe to this Completable and once that is completed then
will subscribe to the
next Observable. |
<T> Single<T> |
andThen(Single<T> next)
Returns a Single which will subscribe to this Completable and once that is completed then
will subscribe to the
next Single. |
void |
await()
Subscribes to and awaits the termination of this Completable instance in a blocking manner and
rethrows any exception emitted.
|
boolean |
await(long timeout,
java.util.concurrent.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.
|
static Completable |
complete()
Returns a Completable instance that completes immediately when subscribed to.
|
Completable |
compose(Completable.Transformer transformer)
Calls the given transformer function with this instance and returns the function's resulting
Completable.
|
static Completable |
concat(Completable... sources)
Returns a Completable which completes only when all sources complete, one after another.
|
static Completable |
concat(java.lang.Iterable<? extends Completable> sources)
Returns a Completable which completes only when all sources complete, one after another.
|
static Completable |
concat(Observable<? extends Completable> sources)
Returns a Completable which completes only when all sources complete, one after another.
|
static Completable |
concat(Observable<? extends Completable> sources,
int prefetch)
Returns a Completable which completes only when all sources complete, one after another.
|
Completable |
concatWith(Completable other)
Concatenates this Completable with another Completable.
|
static Completable |
create(Completable.OnSubscribe onSubscribe)
Constructs a Completable instance by wrapping the given onSubscribe callback.
|
static Completable |
defer(Func0<? extends Completable> completableFunc0)
Defers the subscription to a Completable instance returned by a supplier.
|
Completable |
delay(long delay,
java.util.concurrent.TimeUnit unit)
Returns a Completable which delays the emission of the completion event by the given time.
|
Completable |
delay(long delay,
java.util.concurrent.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.
|
Completable |
delay(long delay,
java.util.concurrent.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.
|
Completable |
doAfterTerminate(Action0 onAfterTerminate)
Returns a Completable instance that calls the given onAfterComplete callback after this
Completable completes normally.
|
Completable |
doOnCompleted(Action0 onCompleted)
Returns a Completable which calls the given onCompleted callback if this Completable completes.
|
Completable |
doOnEach(Action1<Notification<java.lang.Object>> onNotification)
Returns a Completable which calls the given onNotification callback when this Completable emits an error or completes.
|
Completable |
doOnError(Action1<? super java.lang.Throwable> onError)
Returns a Completable which calls the given onError callback if this Completable emits an error.
|
protected Completable |
doOnLifecycle(Action1<? super Subscription> onSubscribe,
Action1<? super java.lang.Throwable> onError,
Action0 onComplete,
Action0 onAfterTerminate,
Action0 onUnsubscribe)
Returns a Completable instance that calls the various callbacks on the specific
lifecycle events.
|
Completable |
doOnSubscribe(Action1<? super Subscription> onSubscribe)
Returns a Completable instance that calls the given onSubscribe callback with the disposable
that child subscribers receive on subscription.
|
Completable |
doOnTerminate(Action0 onTerminate)
Returns a Completable instance that calls the given onTerminate callback just before this Completable
completes normally or with an exception
|
Completable |
doOnUnsubscribe(Action0 onUnsubscribe)
Returns a Completable which calls the given onUnsubscribe callback if the child subscriber cancels
the subscription.
|
static Completable |
error(Func0<? extends java.lang.Throwable> errorFunc0)
Creates a Completable which calls the given error supplier for each subscriber
and emits its returned Throwable.
|
static Completable |
error(java.lang.Throwable error)
Creates a Completable instance that emits the given Throwable exception to subscribers.
|
static Completable |
fromAction(Action0 action)
Returns a Completable instance that runs the given Action0 for each subscriber and
emits either an unchecked exception or simply completes.
|
static Completable |
fromCallable(java.util.concurrent.Callable<?> callable)
Returns a Completable which when subscribed, executes the callable function, ignores its
normal result and emits onError or onCompleted only.
|
static Completable |
fromEmitter(Action1<CompletableEmitter> producer)
Provides an API (in a cold Completable) that bridges the Completable-reactive world
with the callback-based world.
|
static Completable |
fromFuture(java.util.concurrent.Future<?> future)
Returns a Completable instance that reacts to the termination of the given Future in a blocking fashion.
|
static Completable |
fromObservable(Observable<?> flowable)
Returns a Completable instance that subscribes to the given flowable, ignores all values and
emits only the terminal event.
|
static Completable |
fromSingle(Single<?> 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.
|
java.lang.Throwable |
get()
Subscribes to this Completable instance and blocks until it terminates, then returns null or
the emitted exception if any.
|
java.lang.Throwable |
get(long timeout,
java.util.concurrent.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.
|
Completable |
lift(Completable.Operator onLift)
Lifts a CompletableSubscriber transformation into the chain of Completables.
|
static Completable |
merge(Completable... 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(java.lang.Iterable<? extends Completable> 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(Observable<? extends Completable> 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(Observable<? extends Completable> 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.
|
protected static Completable |
merge0(Observable<? extends Completable> sources,
int maxConcurrency,
boolean delayErrors)
Returns a Completable instance that keeps subscriptions to a limited number of sources at once and
completes only when all source Completables terminate in one way or another, combining any exceptions
thrown by either the sources Observable or the inner Completable instances.
|
static Completable |
mergeDelayError(Completable... sources)
Returns a Completable 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(java.lang.Iterable<? extends Completable> 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(Observable<? extends Completable> 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(Observable<? extends Completable> 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.
|
Completable |
mergeWith(Completable 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.
|
Completable |
observeOn(Scheduler scheduler)
Returns a Completable which emits the terminal events from the thread of the specified scheduler.
|
Completable |
onErrorComplete()
Returns a Completable instance that if this Completable emits an error, it will emit an onComplete
and swallow the throwable.
|
Completable |
onErrorComplete(Func1<? super java.lang.Throwable,java.lang.Boolean> 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.
|
Completable |
onErrorResumeNext(Func1<? super java.lang.Throwable,? extends Completable> 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.
|
Completable |
repeat()
Returns a Completable that repeatedly subscribes to this Completable until cancelled.
|
Completable |
repeat(long times)
Returns a Completable that subscribes repeatedly at most the given times to this Completable.
|
Completable |
repeatWhen(Func1<? super Observable<? extends java.lang.Void>,? extends Observable<?>> 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.
|
Completable |
retry()
Returns a Completable that retries this Completable as long as it emits an onError event.
|
Completable |
retry(Func2<java.lang.Integer,java.lang.Throwable,java.lang.Boolean> predicate)
Returns a Completable that retries this Completable in case of an error as long as the predicate
returns true.
|
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.
|
Completable |
retryWhen(Func1<? super Observable<? extends java.lang.Throwable>,? extends Observable<?>> handler)
Returns a Completable which given a Publisher and when this Completable emits an error, delivers
that error through an Observable and the Publisher should return a value indicating a retry in response
or a terminal event indicating a termination.
|
Completable |
startWith(Completable other)
Returns a Completable which first runs the other Completable
then this completable if the other completed normally.
|
<T> Observable<T> |
startWith(Observable<T> other)
Returns an Observable which first delivers the events
of the other Observable then runs this Completable.
|
Subscription |
subscribe()
Subscribes to this Completable and returns a Subscription which can be used to cancel
the subscription.
|
Subscription |
subscribe(Action0 onComplete)
Subscribes to this Completable and calls the given Action0 when this Completable
completes normally.
|
Subscription |
subscribe(Action0 onComplete,
Action1<? super java.lang.Throwable> onError)
Subscribes to this Completable and calls back either the onError or onComplete functions.
|
void |
subscribe(CompletableSubscriber s)
Subscribes the given CompletableSubscriber to this Completable instance
and handles exceptions thrown by its onXXX methods.
|
<T> void |
subscribe(Subscriber<T> s)
Subscribes a regular Subscriber to this Completable instance which
will receive only an onError or onComplete event
and handles exceptions thrown by its onXXX methods.
|
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.
|
AssertableSubscriber<java.lang.Void> |
test()
Creates an AssertableSubscriber that requests
Long.MAX_VALUE and subscribes
it to this Observable. |
Completable |
timeout(long timeout,
java.util.concurrent.TimeUnit unit)
Returns a Completable that runs this Completable and emits a TimeoutException in case
this Completable doesn't complete within the given time.
|
Completable |
timeout(long timeout,
java.util.concurrent.TimeUnit unit,
Completable 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.
|
Completable |
timeout(long timeout,
java.util.concurrent.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.
|
Completable |
timeout(long timeout,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler,
Completable 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.
|
Completable |
timeout0(long timeout,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler,
Completable other)
Returns a Completable that runs this Completable and optionally switches to the other Completable
in case this Completable doesn't complete within the given time while "waiting" on
the specified scheduler.
|
static Completable |
timer(long delay,
java.util.concurrent.TimeUnit unit)
Returns a Completable instance that fires its onComplete event after the given delay elapsed.
|
static Completable |
timer(long delay,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns a Completable instance that fires its onCompleted event after the given delay elapsed
by using the supplied scheduler.
|
<R> R |
to(Func1<? super Completable,R> converter)
Calls the specified converter function during assembly time and returns its resulting value.
|
<T> Observable<T> |
toObservable()
Returns an Observable which when subscribed to subscribes to this Completable and
relays the terminal events to the subscriber.
|
<T> Single<T> |
toSingle(Func0<? extends T> completionValueFunc0)
Converts this Completable into a Single which when this Completable completes normally,
calls the given supplier and emits its returned value through onSuccess.
|
<T> Single<T> |
toSingleDefault(T completionValue)
Converts this Completable into a Single which when this Completable completes normally,
emits the given value through onSuccess.
|
void |
unsafeSubscribe(CompletableSubscriber s)
Subscribes the given CompletableSubscriber to this Completable instance.
|
<T> void |
unsafeSubscribe(Subscriber<T> s)
Subscribes a regular Subscriber to this Completable instance which
will receive only an onError or onComplete event.
|
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(Func0<R> resourceFunc0,
Func1<? super R,? extends Completable> completableFunc1,
Action1<? super R> disposer)
Returns a Completable instance which manages a resource along
with a custom Completable instance while the subscription is active.
|
static <R> Completable |
using(Func0<R> resourceFunc0,
Func1<? super R,? extends Completable> completableFunc1,
Action1<? 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.
|
protected Completable(Completable.OnSubscribe onSubscribe)
onSubscribe
- the callback that will receive CompletableSubscribers when they subscribe,
not null (not verified)protected Completable(Completable.OnSubscribe onSubscribe, boolean useHook)
onSubscribe
- the callback that will receive CompletableSubscribers when they subscribe,
not null (not verified)useHook
- if false, RxJavaHooks.onCreate won't be calledpublic static Completable amb(Completable... sources)
sources
- the array of source Completablesjava.lang.NullPointerException
- if sources is nullpublic static Completable amb(java.lang.Iterable<? extends Completable> sources)
sources
- the array of source Completablesjava.lang.NullPointerException
- if sources is nullpublic static Completable complete()
public static Completable concat(Completable... sources)
sources
- the sources to concatenatejava.lang.NullPointerException
- if sources is nullpublic static Completable concat(java.lang.Iterable<? extends Completable> sources)
sources
- the sources to concatenatejava.lang.NullPointerException
- if sources is nullpublic static Completable concat(Observable<? extends Completable> sources)
sources
- the sources to concatenatejava.lang.NullPointerException
- if sources is nullpublic static Completable concat(Observable<? extends Completable> sources, int prefetch)
sources
- the sources to concatenateprefetch
- the number of sources to prefetch from the sourcesjava.lang.NullPointerException
- if sources is nullpublic static Completable create(Completable.OnSubscribe onSubscribe)
onSubscribe
- the callback which will receive the CompletableSubscriber instances
when the Completable is subscribed to.java.lang.NullPointerException
- if onSubscribe is nullpublic static Completable defer(Func0<? extends Completable> completableFunc0)
completableFunc0
- the supplier that returns the Completable that will be subscribed to.public static Completable error(Func0<? extends java.lang.Throwable> errorFunc0)
If the errorFunc0 returns null, the child CompletableSubscribers will receive a NullPointerException.
errorFunc0
- the error supplier, not nulljava.lang.NullPointerException
- if errorFunc0 is nullpublic static Completable error(java.lang.Throwable error)
error
- the Throwable instance to emit, not nulljava.lang.NullPointerException
- if error is nullpublic static Completable fromAction(Action0 action)
action
- the Action0 to run for each subscriberjava.lang.NullPointerException
- if run is nullpublic static Completable fromCallable(java.util.concurrent.Callable<?> callable)
callable
- the callable instance to execute for each subscriberpublic static Completable fromEmitter(Action1<CompletableEmitter> producer)
The CompletableEmitter
allows registering a callback for
cancellation/unsubscription of a resource.
Example:
Completable.fromEmitter(emitter -> {
Callback listener = new Callback() {
@Override
public void onEvent(Event e) {
emitter.onCompleted();
}
@Override
public void onFailure(Exception e) {
emitter.onError(e);
}
};
AutoCloseable c = api.someMethod(listener);
emitter.setCancellation(c::close);
});
All of the CompletableEmitter's methods are thread-safe and ensure the Completable's protocol are held.
producer
- the callback invoked for each incoming CompletableSubscriberpublic static Completable fromFuture(java.util.concurrent.Future<?> future)
Note that cancellation from any of the subscribers to this Completable will cancel the future.
future
- the future to react topublic static Completable fromObservable(Observable<?> flowable)
flowable
- the Flowable instance to subscribe to, not nulljava.lang.NullPointerException
- if flowable is nullpublic static Completable fromSingle(Single<?> single)
single
- the Single instance to subscribe to, not nulljava.lang.NullPointerException
- if single is nullpublic static Completable merge(Completable... sources)
sources
- the iterable sequence of sources.java.lang.NullPointerException
- if sources is nullpublic static Completable merge(java.lang.Iterable<? extends Completable> sources)
sources
- the iterable sequence of sources.java.lang.NullPointerException
- if sources is nullpublic static Completable merge(Observable<? extends Completable> sources)
sources
- the iterable sequence of sources.java.lang.NullPointerException
- if sources is nullpublic static Completable merge(Observable<? extends Completable> sources, int maxConcurrency)
sources
- the iterable sequence of sources.maxConcurrency
- the maximum number of concurrent subscriptionsjava.lang.NullPointerException
- if sources is nulljava.lang.IllegalArgumentException
- if maxConcurrency is less than 1protected static Completable merge0(Observable<? extends Completable> sources, int maxConcurrency, boolean delayErrors)
sources
- the iterable sequence of sources.maxConcurrency
- the maximum number of concurrent subscriptionsdelayErrors
- delay all errors from the main source and from the inner Completables?java.lang.NullPointerException
- if sources is nulljava.lang.IllegalArgumentException
- if maxConcurrency is less than 1public static Completable mergeDelayError(Completable... sources)
sources
- the array of Completablesjava.lang.NullPointerException
- if sources is nullpublic static Completable mergeDelayError(java.lang.Iterable<? extends Completable> sources)
sources
- the sequence of Completablesjava.lang.NullPointerException
- if sources is nullpublic static Completable mergeDelayError(Observable<? extends Completable> sources)
sources
- the sequence of Completablesjava.lang.NullPointerException
- if sources is nullpublic static Completable mergeDelayError(Observable<? extends Completable> sources, int maxConcurrency)
sources
- the sequence of CompletablesmaxConcurrency
- the maximum number of simultaneous subscriptions to the source Completables.java.lang.NullPointerException
- if sources is nullpublic static Completable never()
public static Completable timer(long delay, java.util.concurrent.TimeUnit unit)
delay
- the delay timeunit
- the delay unitpublic static Completable timer(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
delay
- the delay timeunit
- the delay unitscheduler
- the scheduler to use to emit the onCompleted eventpublic static <R> Completable using(Func0<R> resourceFunc0, Func1<? super R,? extends Completable> completableFunc1, Action1<? super R> disposer)
This overload performs an eager unsubscription before the terminal event is emitted.
R
- the resource typeresourceFunc0
- the supplier that returns a resource to be managed.completableFunc1
- the function that given a resource returns a Completable instance that will be subscribed todisposer
- the consumer that disposes the resource created by the resource supplierpublic static <R> Completable using(Func0<R> resourceFunc0, Func1<? super R,? extends Completable> completableFunc1, Action1<? super R> disposer, boolean eager)
If this overload performs a lazy unsubscription after the terminal event is emitted. Exceptions thrown at this time will be delivered to RxJavaPlugins only.
R
- the resource typeresourceFunc0
- the supplier that returns a resource to be managedcompletableFunc1
- the function that given a resource returns a non-null
Completable instance that will be subscribed todisposer
- the consumer that disposes the resource created by the resource suppliereager
- if true, the resource is disposed before the terminal event is emitted, if false, the
resource is disposed after the terminal event has been emittedpublic final Completable ambWith(Completable other)
other
- the other Completable, not nulljava.lang.NullPointerException
- if other is nullpublic final void await()
java.lang.RuntimeException
- wrapping an InterruptedException if the current thread is interruptedpublic final boolean await(long timeout, java.util.concurrent.TimeUnit unit)
timeout
- the timeout valueunit
- the timeout unitjava.lang.RuntimeException
- wrapping an InterruptedException if the current thread is interruptedpublic final Completable compose(Completable.Transformer transformer)
transformer
- the transformer function, not nulljava.lang.NullPointerException
- if transformer is nullpublic final <T> Observable<T> andThen(Observable<T> next)
next
Observable. An error event from this Completable will be
propagated to the downstream subscriber and will result in skipping the subscription of the
Observable.T
- the value type of the next Observablenext
- the Observable to subscribe after this Completable is completed, not nulljava.lang.NullPointerException
- if next is nullpublic final <T> Single<T> andThen(Single<T> next)
next
Single. 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
.T
- the value type of the next Singlenext
- the Single to subscribe after this Completable is completed, not nullpublic final Completable andThen(Completable next)
This is an alias for concatWith(Completable)
.
next
- the other Completable, not nulljava.lang.NullPointerException
- if other is nullpublic final Completable concatWith(Completable other)
other
- the other Completable, not nulljava.lang.NullPointerException
- if other is nullpublic final Completable delay(long delay, java.util.concurrent.TimeUnit unit)
delay
- the delay timeunit
- the delay unitjava.lang.NullPointerException
- if unit is nullpublic final Completable delay(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
delay
- the delay timeunit
- the delay unitscheduler
- the scheduler to run the delayed completion onjava.lang.NullPointerException
- if unit or scheduler is nullpublic final Completable delay(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler, boolean delayError)
delay
- the delay timeunit
- the delay unitscheduler
- the scheduler to run the delayed completion ondelayError
- delay the error emission as well?java.lang.NullPointerException
- if unit or scheduler is nullpublic final Completable doOnCompleted(Action0 onCompleted)
onCompleted
- the callback to call when this emits an onComplete eventjava.lang.NullPointerException
- if onComplete is nullpublic final Completable doOnEach(Action1<Notification<java.lang.Object>> onNotification)
onNotification
- the notification callbackjava.lang.NullPointerException
- if onNotification is nullpublic final Completable doOnUnsubscribe(Action0 onUnsubscribe)
onUnsubscribe
- the callback to call when the child subscriber cancels the subscriptionjava.lang.NullPointerException
- if onDispose is nullpublic final Completable doOnError(Action1<? super java.lang.Throwable> onError)
onError
- the error callbackjava.lang.NullPointerException
- if onError is nullprotected final Completable doOnLifecycle(Action1<? super Subscription> onSubscribe, Action1<? super java.lang.Throwable> onError, Action0 onComplete, Action0 onAfterTerminate, Action0 onUnsubscribe)
onSubscribe
- the consumer called when a CompletableSubscriber subscribes.onError
- the consumer called when this emits an onError eventonComplete
- the runnable called just before when this Completable completes normallyonAfterTerminate
- the runnable called after this Completable terminatesonUnsubscribe
- the runnable called when the child cancels the subscriptionpublic final Completable doOnSubscribe(Action1<? super Subscription> onSubscribe)
onSubscribe
- the callback called when a child subscriber subscribesjava.lang.NullPointerException
- if onSubscribe is nullpublic final Completable doOnTerminate(Action0 onTerminate)
onTerminate
- the callback to call just before this Completable terminatespublic final Completable doAfterTerminate(Action0 onAfterTerminate)
onAfterTerminate
- the callback to call after this Completable emits an onCompleted or onError event.java.lang.NullPointerException
- if onAfterComplete is nullpublic final java.lang.Throwable get()
java.lang.RuntimeException
- that wraps an InterruptedException if the wait is interruptedpublic final java.lang.Throwable get(long timeout, java.util.concurrent.TimeUnit unit)
timeout
- the time amount to wait for the terminal eventunit
- the time unit of the timeout parameterjava.lang.RuntimeException
- that wraps an InterruptedException if the wait is interrupted or
TimeoutException if the specified timeout elapsed before itpublic final Completable lift(Completable.Operator onLift)
onLift
- the lifting function that transforms the child subscriber with a parent subscriber.java.lang.NullPointerException
- if onLift is nullpublic final Completable mergeWith(Completable other)
other
- the other Completable instancejava.lang.NullPointerException
- if other is nullpublic final Completable observeOn(Scheduler scheduler)
scheduler
- the scheduler to emit terminal events onjava.lang.NullPointerException
- if scheduler is nullpublic final Completable onErrorComplete()
public final Completable onErrorComplete(Func1<? super java.lang.Throwable,java.lang.Boolean> predicate)
predicate
- the predicate to call when a Throwable is emitted which should return true
if the Throwable should be swallowed and replaced with an onComplete.public final Completable onErrorResumeNext(Func1<? super java.lang.Throwable,? extends Completable> errorMapper)
errorMapper
- the mapper function that takes the error and should return a Completable as
continuation.public final Completable repeat()
public final Completable repeat(long times)
times
- the number of times the resubscription should happenjava.lang.IllegalArgumentException
- if times is less than zeropublic final Completable repeatWhen(Func1<? super Observable<? extends java.lang.Void>,? extends Observable<?>> handler)
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 stopjava.lang.NullPointerException
- if stop is nullpublic final Completable retry()
public final Completable retry(Func2<java.lang.Integer,java.lang.Throwable,java.lang.Boolean> predicate)
predicate
- the predicate called when this emits an error with the repeat count and the latest exception
and should return true to retry.public final Completable retry(long times)
times
- the number of times the returned Completable should retry this Completablejava.lang.IllegalArgumentException
- if times is negativepublic final Completable retryWhen(Func1<? super Observable<? extends java.lang.Throwable>,? extends Observable<?>> handler)
handler
- the handler that receives an Observable delivering Throwables and should return a Publisher that
emits items to indicate retries or emits terminal events to indicate termination.java.lang.NullPointerException
- if handler is nullpublic final Completable startWith(Completable other)
other
- the other completable to run firstjava.lang.NullPointerException
- if other is nullpublic final <T> Observable<T> startWith(Observable<T> other)
T
- the value type of the starting other Observableother
- the other Observable to run firstjava.lang.NullPointerException
- if other is nullpublic final Subscription subscribe()
public final Subscription subscribe(Action0 onComplete)
If this Completable emits an error, it is sent to RxJavaHooks.onError and gets swallowed.
onComplete
- the runnable called when this Completable completes normallypublic final Subscription subscribe(Action0 onComplete, Action1<? super java.lang.Throwable> onError)
onComplete
- the runnable that is called if the Completable completes normallyonError
- the consumer that is called if this Completable emits an errorjava.lang.NullPointerException
- if either callback is nullpublic final void unsafeSubscribe(CompletableSubscriber s)
s
- the CompletableSubscriber, not nulljava.lang.NullPointerException
- if s is nullpublic final void subscribe(CompletableSubscriber s)
s
- the CompletableSubscriber, not nulljava.lang.NullPointerException
- if s is nullpublic final <T> void unsafeSubscribe(Subscriber<T> s)
T
- the value type of the subscribers
- the reactive-streams Subscriber, not nulljava.lang.NullPointerException
- if s is nullpublic final <T> void subscribe(Subscriber<T> s)
T
- the value type of the subscribers
- the reactive-streams Subscriber, not nulljava.lang.NullPointerException
- if s is nullpublic final Completable subscribeOn(Scheduler scheduler)
scheduler
- the Scheduler to subscribe onjava.lang.NullPointerException
- if scheduler is nullpublic final Completable timeout(long timeout, java.util.concurrent.TimeUnit unit)
timeout
- the timeout valueunit
- the timeout unitjava.lang.NullPointerException
- if unit is nullpublic final Completable timeout(long timeout, java.util.concurrent.TimeUnit unit, Completable other)
timeout
- the timeout valueunit
- the timeout unitother
- the other Completable instance to switch to in case of a timeoutjava.lang.NullPointerException
- if unit or other is nullpublic final Completable timeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
timeout
- the timeout valueunit
- the timeout unitscheduler
- the scheduler to use to wait for completionjava.lang.NullPointerException
- if unit or scheduler is nullpublic final Completable timeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler, Completable other)
timeout
- the timeout valueunit
- the timeout unitscheduler
- the scheduler to use to wait for completionother
- the other Completable instance to switch to in case of a timeoutjava.lang.NullPointerException
- if unit, scheduler or other is nullpublic final Completable timeout0(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler, Completable other)
timeout
- the timeout valueunit
- the timeout unitscheduler
- the scheduler to use to wait for completionother
- the other Completable instance to switch to in case of a timeout,
if null a TimeoutException is emitted insteadjava.lang.NullPointerException
- if unit or schedulerpublic final <R> R to(Func1<? super Completable,R> converter)
This allows fluent conversion to any other type.
R
- the resulting object typeconverter
- the function that receives the current Single instance and returns a valuepublic final <T> Observable<T> toObservable()
T
- the target type of the Observablepublic final <T> Single<T> toSingle(Func0<? extends T> completionValueFunc0)
T
- the value type of the resulting SinglecompletionValueFunc0
- the value supplier called when this Completable completes normallyjava.lang.NullPointerException
- if completionValueFunc0 is nullpublic final <T> Single<T> toSingleDefault(T completionValue)
T
- the value type of the resulting SinglecompletionValue
- the value to emit when this Completable completes normallyjava.lang.NullPointerException
- if completionValue is nullpublic final Completable unsubscribeOn(Scheduler scheduler)
scheduler
- the target scheduler where to execute the cancellationjava.lang.NullPointerException
- if scheduler is nullpublic final AssertableSubscriber<java.lang.Void> test()
Long.MAX_VALUE
and subscribes
it to this Observable.
test
does not operate by default on a particular Scheduler
.History: 1.2.3 - experimental