public abstract class Completable
extends java.lang.Object
CompletableSource.Subscriber
as such calls are
ambiguous about the intent whether the subscribe is part of the same source (a.k.a an operator) or it is a terminal
subscribe. If it is required to subscribe to a source, then a source adapter
can be used to
convert to a CompletableSource
.Modifier | Constructor and Description |
---|---|
protected |
Completable()
New instance.
|
Modifier and Type | Method and Description |
---|---|
Completable |
afterCancel(java.lang.Runnable onCancel)
Invokes the
onCancel Runnable argument after Cancellable.cancel() is
called for Subscriptions of the returned Completable . |
Completable |
afterFinally(java.lang.Runnable doFinally)
Invokes the
whenFinally Runnable argument after any of the following terminal
methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
for Subscriptions/CompletableSource.Subscriber s of the returned Completable . |
Completable |
afterOnComplete(java.lang.Runnable onComplete)
Invokes the
onComplete Runnable argument after CompletableSource.Subscriber.onComplete()
is called for CompletableSource.Subscriber s of the returned Completable . |
Completable |
afterOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes the
onError Consumer argument after
CompletableSource.Subscriber.onError(Throwable) is called for CompletableSource.Subscriber s of the returned Completable . |
Completable |
afterOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
Invokes the
onSubscribe Consumer argument after
CompletableSource.Subscriber.onSubscribe(Cancellable) is called for CompletableSource.Subscriber s of the returned
Completable . |
Completable |
afterSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
Creates a new
CompletableSource.Subscriber (via the subscriberSupplier argument) on each call to
subscribe and invokes all the CompletableSource.Subscriber methods after the CompletableSource.Subscriber s of the
returned Completable . |
Completable |
beforeCancel(java.lang.Runnable onCancel)
Invokes the
onCancel Runnable argument before Cancellable.cancel() is
called for Subscriptions of the returned Completable . |
Completable |
beforeFinally(java.lang.Runnable doFinally)
Invokes the
whenFinally Runnable argument before any of the following terminal
methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
for Subscriptions/CompletableSource.Subscriber s of the returned Completable . |
Completable |
beforeOnComplete(java.lang.Runnable onComplete)
Invokes the
onComplete Runnable argument before CompletableSource.Subscriber.onComplete()
is called for CompletableSource.Subscriber s of the returned Completable . |
Completable |
beforeOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes the
onError Consumer argument before
CompletableSource.Subscriber.onError(Throwable) is called for CompletableSource.Subscriber s of the returned Completable . |
Completable |
beforeOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
Invokes the
onSubscribe Consumer argument before
CompletableSource.Subscriber.onSubscribe(Cancellable) is called for CompletableSource.Subscriber s of the returned
Completable . |
Completable |
beforeSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
Creates a new
CompletableSource.Subscriber (via the subscriberSupplier argument) on each call to
subscribe and invokes all the CompletableSource.Subscriber methods before the CompletableSource.Subscriber s of the
returned Completable . |
static Completable |
completed()
Creates a realized completed
Completable . |
Completable |
concat(Completable next)
Once this
Completable is terminated successfully, subscribe to next Completable
and propagate its terminal signal to the returned Completable . |
<T> Publisher<T> |
concat(Publisher<? extends T> next)
Once this
Completable is terminated successfully, subscribe to next Publisher
and propagate all emissions to the returned Publisher . |
<T> Single<T> |
concat(Single<? extends T> next)
Once this
Completable is terminated successfully, subscribe to next Single
and propagate the result to the returned Single . |
static Completable |
defer(java.util.function.Supplier<? extends Completable> completableSupplier)
Defer creation of a
Completable till it is subscribed to. |
static Completable |
failed(java.lang.Throwable cause)
Creates a realized failed
Completable . |
static Completable |
fromFuture(java.util.concurrent.Future<?> future)
|
static Completable |
fromRunnable(java.lang.Runnable runnable)
Creates a
Completable which when subscribed will invoke Runnable.run() on the passed
Runnable and emit the value returned by that invocation from the returned Completable . |
static Completable |
fromStage(java.util.concurrent.CompletionStage<?> stage)
Convert from a
CompletionStage to a Completable . |
protected abstract void |
handleSubscribe(CompletableSource.Subscriber subscriber)
Handles a subscriber to this
Completable . |
Completable |
idleTimeout(java.time.Duration duration)
Creates a new
Completable that will mimic the signals of this Completable but will terminate
with a TimeoutException if time duration elapses between subscribe and termination. |
Completable |
idleTimeout(java.time.Duration duration,
Executor timeoutExecutor)
Creates a new
Completable that will mimic the signals of this Completable but will terminate
with a TimeoutException if time duration elapses between subscribe and termination. |
Completable |
idleTimeout(long duration,
java.util.concurrent.TimeUnit unit)
Creates a new
Completable that will mimic the signals of this Completable but will terminate
with a TimeoutException if time duration elapses between subscribe and termination. |
Completable |
idleTimeout(long duration,
java.util.concurrent.TimeUnit unit,
Executor timeoutExecutor)
Creates a new
Completable that will mimic the signals of this Completable but will terminate
with a TimeoutException if time duration elapses between subscribe and termination. |
Completable |
liftAsync(CompletableOperator operator)
This method requires advanced knowledge of building operators.
|
Completable |
liftSync(CompletableOperator operator)
This method requires advanced knowledge of building operators.
|
Completable |
merge(Completable... other)
Merges this
Completable with the other Completable s so that the resulting
Completable terminates successfully when all of these complete or terminates with an error when any one
terminates with an error. |
Completable |
merge(java.lang.Iterable<? extends Completable> other)
Merges this
Completable with the other Completable s so that the resulting
Completable terminates successfully when all of these complete or terminates with an error when any one
terminates with an error. |
<T> Publisher<T> |
merge(Publisher<? extends T> mergeWith)
Merges the passed
Publisher with this Completable . |
static Completable |
mergeAll(Completable... completables)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAll(int maxConcurrency,
Completable... completables)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAll(java.lang.Iterable<? extends Completable> completables)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAll(java.lang.Iterable<? extends Completable> completables,
int maxConcurrency)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAllDelayError(Completable... completables)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAllDelayError(int maxConcurrency,
Completable... completables)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAllDelayError(java.lang.Iterable<? extends Completable> completables)
Returns a
Completable that terminates when all the passed Completable terminate. |
static Completable |
mergeAllDelayError(java.lang.Iterable<? extends Completable> completables,
int maxConcurrency)
Returns a
Completable that terminates when all the passed Completable terminate. |
Completable |
mergeDelayError(Completable... other)
Merges this
Completable with the other Completable s, and delays error notification until
all involved Completable s terminate. |
Completable |
mergeDelayError(java.lang.Iterable<? extends Completable> other)
Merges this
Completable with the other Completable s, and delays error notification until
all involved Completable s terminate. |
static Completable |
never()
Creates a
Completable that never terminates. |
Completable |
onErrorResume(java.util.function.Function<java.lang.Throwable,? extends Completable> nextFactory)
Recover from any error emitted by this
Completable by using another Completable provided by the
passed nextFactory . |
Completable |
publishAndSubscribeOn(Executor executor)
Creates a new
Completable that will use the passed Executor to invoke the following methods:
All CompletableSource.Subscriber methods.
All Cancellable methods.
The handleSubscribe(CompletableSource.Subscriber) method.
This method does not override preceding Executor s, if any, specified for this
Completable . |
Completable |
publishAndSubscribeOnOverride(Executor executor)
Creates a new
Completable that will use the passed Executor to invoke the following methods:
All CompletableSource.Subscriber methods.
All Cancellable methods.
The handleSubscribe(CompletableSource.Subscriber) method.
This method overrides preceding Executor s, if any, specified for this Completable . |
Completable |
publishOn(Executor executor)
Creates a new
Completable that will use the passed Executor to invoke all CompletableSource.Subscriber
methods. |
Completable |
publishOnOverride(Executor executor)
Creates a new
Completable that will use the passed Executor to invoke all CompletableSource.Subscriber
methods. |
Publisher<java.lang.Void> |
repeat(java.util.function.IntPredicate shouldRepeat)
|
Publisher<java.lang.Void> |
repeatWhen(java.util.function.IntFunction<? extends Completable> repeatWhen)
Re-subscribes to this
Completable when it completes and the Completable returned by the supplied
IntFunction completes successfully. |
Completable |
retry(BiIntPredicate<java.lang.Throwable> shouldRetry)
Re-subscribes to this
Completable if an error is emitted and the passed BiIntPredicate returns
true . |
Completable |
retryWhen(BiIntFunction<java.lang.Throwable,? extends Completable> retryWhen)
Re-subscribes to this
Completable if an error is emitted and the Completable returned by the
supplied BiIntFunction completes successfully. |
Cancellable |
subscribe()
Subscribe to this
Completable and log any CompletableSource.Subscriber.onError(Throwable) . |
Cancellable |
subscribe(java.lang.Runnable onComplete)
Subscribe to this
Completable and log any CompletableSource.Subscriber.onError(Throwable) . |
protected void |
subscribeInternal(CompletableSource.Subscriber subscriber)
A internal subscribe method similar to
CompletableSource.subscribe(Subscriber) which can be used by
different implementations to subscribe. |
Completable |
subscribeOn(Executor executor)
Creates a new
Completable that will use the passed Executor to invoke the following methods:
All Cancellable methods.
The handleSubscribe(CompletableSource.Subscriber) method.
This method does not override preceding Executor s, if any, specified for this
Completable . |
Completable |
subscribeOnOverride(Executor executor)
Creates a new
Completable that will use the passed Executor to invoke the following methods:
All Cancellable methods.
The handleSubscribe(CompletableSource.Subscriber) method.
This method overrides preceding Executor s, if any, specified for this Completable . |
Completable |
subscribeShareContext()
Signifies that when the returned
Completable is subscribed to, the AsyncContext will be shared
instead of making a copy . |
java.util.concurrent.CompletionStage<java.lang.Void> |
toCompletionStage()
Converts this
Completable to a CompletionStage . |
java.util.concurrent.Future<java.lang.Void> |
toFuture()
Converts this
Completable to a Future . |
<T> Publisher<T> |
toPublisher()
Converts this
Completable to a Publisher . |
Single<java.lang.Void> |
toSingle()
Converts this
Completable to a Single . |
Completable |
whenCancel(java.lang.Runnable onCancel)
Invokes the
onCancel Runnable argument when Cancellable.cancel() is called for
Subscriptions of the returned Completable . |
Completable |
whenFinally(java.lang.Runnable doFinally)
Invokes the
whenFinally Runnable argument exactly once, when any of the following terminal
methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
for Subscriptions/CompletableSource.Subscriber s of the returned Completable . |
Completable |
whenOnComplete(java.lang.Runnable onComplete)
Invokes the
onComplete Runnable argument when CompletableSource.Subscriber.onComplete() is called for
CompletableSource.Subscriber s of the returned Completable . |
Completable |
whenOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes the
onError Consumer argument when CompletableSource.Subscriber.onError(Throwable) is called for
CompletableSource.Subscriber s of the returned Completable . |
Completable |
whenOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
Invokes the
onSubscribe Consumer argument when
CompletableSource.Subscriber.onSubscribe(Cancellable) is called for CompletableSource.Subscriber s of the returned
Completable . |
Completable |
whenSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
Creates a new
CompletableSource.Subscriber (via the subscriberSupplier argument) for each new subscribe and
invokes methods on that CompletableSource.Subscriber when the corresponding methods are called for CompletableSource.Subscriber s of
the returned Publisher . |
public final Completable onErrorResume(java.util.function.Function<java.lang.Throwable,? extends Completable> nextFactory)
Completable
by using another Completable
provided by the
passed nextFactory
.
This method provides similar capabilities to a try/catch block in sequential programming:
try {
resultOfThisCompletable();
} catch (Throwable cause) {
// Note that nextFactory returning a error Completable is like re-throwing (nextFactory shouldn't throw).
nextFactory.apply(cause);
}
nextFactory
- Returns the next Completable
, if this Completable
emits an error.Completable
that recovers from an error from this Completable
by using another
Completable
provided by the passed nextFactory
.public final Completable whenOnComplete(java.lang.Runnable onComplete)
onComplete
Runnable
argument when CompletableSource.Subscriber.onComplete()
is called for
CompletableSource.Subscriber
s of the returned Completable
.
The order in which onComplete
will be invoked relative to CompletableSource.Subscriber.onComplete()
is
undefined. If you need strict ordering see beforeOnComplete(Runnable)
and
afterOnComplete(Runnable)
.
From a sequential programming point of view this method is roughly equivalent to the following:
// NOTE: The order of operations here is not guaranteed by this method!
nextOperation(result);
onComplete.run();
onComplete
- Invoked when CompletableSource.Subscriber.onComplete()
is called for CompletableSource.Subscriber
s of the returned
Completable
. MUST NOT throw.Completable
.beforeOnComplete(Runnable)
,
afterOnComplete(Runnable)
public final Completable whenOnError(java.util.function.Consumer<java.lang.Throwable> onError)
onError
Consumer
argument when CompletableSource.Subscriber.onError(Throwable)
is called for
CompletableSource.Subscriber
s of the returned Completable
.
The order in which onError
will be invoked relative to CompletableSource.Subscriber.onError(Throwable)
is
undefined. If you need strict ordering see beforeOnError(Consumer)
and
afterOnError(Consumer)
.
From a sequential programming point of view this method is roughly equivalent to the following:
try {
resultOfThisCompletable();
} catch (Throwable cause) {
// NOTE: The order of operations here is not guaranteed by this method!
nextOperation(cause);
onError.accept(cause);
}
onError
- Invoked when CompletableSource.Subscriber.onError(Throwable)
is called for CompletableSource.Subscriber
s of the
returned Completable
. MUST NOT throw.Completable
.beforeOnError(Consumer)
,
afterOnError(Consumer)
public final Completable whenFinally(java.lang.Runnable doFinally)
whenFinally
Runnable
argument exactly once, when any of the following terminal
methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
CompletableSource.Subscriber
s of the returned Completable
.
The order in which whenFinally
will be invoked relative to the above methods is undefined. If you need
strict ordering see beforeFinally(Runnable)
and afterFinally(Runnable)
.
From a sequential programming point of view this method is roughly equivalent to the following:
try {
resultOfThisCompletable();
} finally {
// NOTE: The order of operations here is not guaranteed by this method!
nextOperation(); // Maybe notifying of cancellation, or termination
whenFinally.run();
}
doFinally
- Invoked exactly once, when any of the following terminal methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
CompletableSource.Subscriber
s of the returned Completable
MUST NOT throw.Completable
.afterFinally(Runnable)
,
beforeFinally(Runnable)
public final Completable whenCancel(java.lang.Runnable onCancel)
onCancel
Runnable
argument when Cancellable.cancel()
is called for
Subscriptions of the returned Completable
.
The order in which whenFinally
will be invoked relative to Cancellable.cancel()
is undefined. If
you need strict ordering see beforeCancel(Runnable)
and afterCancel(Runnable)
.
onCancel
- Invoked when Cancellable.cancel()
is called for Subscriptions of the
returned Completable
. MUST NOT throw.Completable
.beforeCancel(Runnable)
,
afterCancel(Runnable)
public final Completable idleTimeout(long duration, java.util.concurrent.TimeUnit unit)
Completable
that will mimic the signals of this Completable
but will terminate
with a TimeoutException
if time duration
elapses between subscribe and termination.
The timer starts when the returned Completable
is subscribed.
In the event of timeout any Cancellable
from CompletableSource.Subscriber.onSubscribe(Cancellable)
will be
cancelled
and the associated CompletableSource.Subscriber
will be
terminated
.
duration
- The time duration which is allowed to elapse before CompletableSource.Subscriber.onComplete()
.unit
- The units for duration
.Completable
that will mimic the signals of this Completable
but will terminate with
a TimeoutException
if time duration
elapses before CompletableSource.Subscriber.onComplete()
.public final Completable idleTimeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)
Completable
that will mimic the signals of this Completable
but will terminate
with a TimeoutException
if time duration
elapses between subscribe and termination.
The timer starts when the returned Completable
is subscribed.
In the event of timeout any Cancellable
from CompletableSource.Subscriber.onSubscribe(Cancellable)
will be
cancelled
and the associated CompletableSource.Subscriber
will be
terminated
.
duration
- The time duration which is allowed to elapse before CompletableSource.Subscriber.onComplete()
.unit
- The units for duration
.timeoutExecutor
- The Executor
to use for managing the timer notifications.Completable
that will mimic the signals of this Completable
but will terminate with
a TimeoutException
if time duration
elapses before CompletableSource.Subscriber.onComplete()
.public final Completable idleTimeout(java.time.Duration duration)
Completable
that will mimic the signals of this Completable
but will terminate
with a TimeoutException
if time duration
elapses between subscribe and termination.
The timer starts when the returned Completable
is subscribed.
In the event of timeout any Cancellable
from CompletableSource.Subscriber.onSubscribe(Cancellable)
will be
cancelled
and the associated CompletableSource.Subscriber
will be
terminated
.
duration
- The time duration which is allowed to elapse before CompletableSource.Subscriber.onComplete()
.Completable
that will mimic the signals of this Completable
but will terminate with
a TimeoutException
if time duration
elapses before CompletableSource.Subscriber.onComplete()
.public final Completable idleTimeout(java.time.Duration duration, Executor timeoutExecutor)
Completable
that will mimic the signals of this Completable
but will terminate
with a TimeoutException
if time duration
elapses between subscribe and termination.
The timer starts when the returned Completable
is subscribed.
In the event of timeout any Cancellable
from CompletableSource.Subscriber.onSubscribe(Cancellable)
will be
cancelled
and the associated CompletableSource.Subscriber
will be
terminated
.
duration
- The time duration which is allowed to elapse before CompletableSource.Subscriber.onComplete()
.timeoutExecutor
- The Executor
to use for managing the timer notifications.Completable
that will mimic the signals of this Completable
but will terminate with
a TimeoutException
if time duration
elapses before CompletableSource.Subscriber.onComplete()
.public final Completable concat(Completable next)
Completable
is terminated successfully, subscribe to next
Completable
and propagate its terminal signal to the returned Completable
. Any error from this Completable
or next
Completable
are propagated to the returned Completable
.
This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
resultOfThisCompletable();
nextCompletable();
next
- Completable
to subscribe after this Completable
terminates successfully.Completable
that emits the terminal signal of next
Completable
, after this
Completable
has terminated successfully.public final <T> Single<T> concat(Single<? extends T> next)
Completable
is terminated successfully, subscribe to next
Single
and propagate the result to the returned Single
. Any error from this Completable
or next
Single
are propagated to the returned Single
.
This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
resultOfThisCompletable();
T result = resultOfNextSingle();
return result;
T
- Type of result of the returned Single
.next
- Single
to subscribe after this Completable
terminates successfully.Single
that emits the result of next
Single
, after this Completable
has terminated successfully.public final <T> Publisher<T> concat(Publisher<? extends T> next)
Completable
is terminated successfully, subscribe to next
Publisher
and propagate all emissions to the returned Publisher
. Any error from this Completable
or
next
Publisher
are propagated to the returned Publisher
.
This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
List<T> results = new ...;
resultOfThisCompletable();
results.addAll(nextStream());
return results;
T
- Type of objects emitted from the returned Publisher
.next
- Publisher
to subscribe after this Completable
terminates successfully.Publisher
that emits all items emitted from next
Publisher
, after this
Completable
has terminated successfully.public final Completable merge(Completable... other)
Completable
with the other
Completable
s so that the resulting
Completable
terminates successfully when all of these complete or terminates with an error when any one
terminates with an error.
This method provides a means to merge multiple asynchronous sources, fails-fast in the presence of any errors, and in sequential programming is similar to:
ExecutorService e = ...;
List<Future<Void>> futures = ...;
futures.add(e.submit(() -> resultOfThisCompletable()));
for (Completable c : other) {
futures.add(e.submit(() -> resultOfCompletable(c));
}
// This is an approximation, this operator does not provide any ordering guarantees for the results.
for (Future<Void> future : futures) {
future.get(); // Throws if the processing for this item failed.
}
other
- Completable
s to merge.Completable
that terminates successfully when this and all other
Completable
s
complete or terminates with an error when any one terminates with an error.public final Completable merge(java.lang.Iterable<? extends Completable> other)
Completable
with the other
Completable
s so that the resulting
Completable
terminates successfully when all of these complete or terminates with an error when any one
terminates with an error.
This method provides a means to merge multiple asynchronous sources, fails-fast in the presence of any errors, and in sequential programming is similar to:
ExecutorService e = ...;
List<Future<Void>> futures = ...;
futures.add(e.submit(() -> resultOfThisCompletable()));
for (Completable c : other) {
futures.add(e.submit(() -> resultOfCompletable(c));
}
// This is an approximation, this operator does not provide any ordering guarantees for the results.
for (Future<Void> future : futures) {
future.get(); // Throws if the processing for this item failed.
}
other
- Completable
s to merge.Completable
that terminates successfully when this and all other
Completable
s
complete or terminates with an error when any one terminates with an error.public final <T> Publisher<T> merge(Publisher<? extends T> mergeWith)
Publisher
with this Completable
.
The resulting Publisher
emits all items emitted by the passed Publisher
and terminates
successfully when both this Completable
and the passed Publisher
terminates successfully.
It terminates with an error when any one of this Completable
or passed Publisher
terminates with
an error.
ExecutorService e = ...;
Future<?> future1 = e.submit(() -> resultOfThisCompletable()));
Future<?> future2 = e.submit(() -> resultOfMergeWithStream());
// This is an approximation, this operator does not provide any ordering guarantees for the results.
future1.get(); // Throws if this Completable failed.
future2.get(); // Throws if mergeWith Publisher failed.
T
- The value type of the resulting Publisher
.mergeWith
- the Publisher
to merge inPublisher
that emits all items emitted by the passed Publisher
and terminates
successfully when both this Completable
and the passed Publisher
terminates successfully.
It terminates with an error when any one of this Completable
or passed Publisher
terminates with
an error.public final Completable mergeDelayError(Completable... other)
Completable
with the other
Completable
s, and delays error notification until
all involved Completable
s terminate.
Use merge(Completable...)
if any error should immediately terminate the returned Completable
.
This method provides a means to merge multiple asynchronous sources, delays throwing in the presence of any errors, and in sequential programming is similar to:
ExecutorService e = ...;
List<Future<Void>> futures = ...;
futures.add(e.submit(() -> resultOfThisCompletable()));
for (Completable c : other) {
futures.add(e.submit(() -> resultOfCompletable(c));
}
Throwable overallCause = null;
// This is an approximation, this operator does not provide any ordering guarantees for the results.
for (Future<Void> future : futures) {
try {
f.get();
} catch (Throwable cause) {
if (overallCause != null) {
overallCause = cause;
}
}
}
if (overallCause != null) {
throw overallCause;
}
other
- Completable
s to merge.Completable
that terminates after this
Completable
and all other
Completable
s. If all involved Completable
s terminate successfully then the return value will
terminate successfully. If any Completable
terminates in an error, then the return value will also
terminate in an error.public final Completable mergeDelayError(java.lang.Iterable<? extends Completable> other)
Completable
with the other
Completable
s, and delays error notification until
all involved Completable
s terminate.
Use merge(Iterable)
if any error should immediately terminate the returned Completable
.
This method provides a means to merge multiple asynchronous sources, delays throwing in the presence of any errors, and in sequential programming is similar to:
ExecutorService e = ...;
List<Future<Void>> futures = ...;
futures.add(e.submit(() -> resultOfThisCompletable()));
for (Completable c : other) {
futures.add(e.submit(() -> resultOfCompletable(c));
}
Throwable overallCause = null;
// This is an approximation, this operator does not provide any ordering guarantees for the results.
for (Future<Void> future : futures) {
try {
f.get();
} catch (Throwable cause) {
if (overallCause != null) {
overallCause = cause;
}
}
}
if (overallCause != null) {
throw overallCause;
}
other
- Completable
s to merge.Completable
that terminates after this
Completable
and all other
Completable
s. If all involved Completable
s terminate successfully then the return value will
terminate successfully. If any Completable
terminates in an error, then the return value will also
terminate in an error.public final Completable retry(BiIntPredicate<java.lang.Throwable> shouldRetry)
Completable
if an error is emitted and the passed BiIntPredicate
returns
true
.
This method provides a means to retry an operation under certain failure conditions and in sequential programming is similar to:
public T execute() {
return execute(0);
}
private T execute(int attempts) {
try {
resultOfThisCompletable();
} catch (Throwable cause) {
if (shouldRetry.apply(attempts + 1, cause)) {
return execute(attempts + 1);
} else {
throw cause;
}
}
}
shouldRetry
- BiIntPredicate
that given the retry count and the most recent Throwable
emitted from this
Completable
determines if the operation should be retried.Completable
that completes with this Completable
or re-subscribes if an error is
emitted and if the passed BiPredicate
returned true
.public final Completable retryWhen(BiIntFunction<java.lang.Throwable,? extends Completable> retryWhen)
Completable
if an error is emitted and the Completable
returned by the
supplied BiIntFunction
completes successfully. If the returned Completable
emits an error, the
returned Completable
terminates with that error.
This method provides a means to retry an operation under certain failure conditions in an asynchronous fashion and in sequential programming is similar to:
public T execute() {
return execute(0);
}
private T execute(int attempts) {
try {
resultOfThisCompletable();
} catch (Throwable cause) {
try {
shouldRetry.apply(attempts + 1, cause); // Either throws or completes normally
execute(attempts + 1);
} catch (Throwable ignored) {
throw cause;
}
}
}
retryWhen
- BiIntFunction
that given the retry count and the most recent Throwable
emitted
from this Completable
returns a Completable
. If this Completable
emits an error, that
error is emitted from the returned Completable
, otherwise, original Completable
is re-subscribed
when this Completable
completes.Completable
that completes with this Completable
or re-subscribes if an error is
emitted and Completable
returned by BiFunction
completes successfully.public final Publisher<java.lang.Void> repeat(java.util.function.IntPredicate shouldRepeat)
Completable
when it completes and the passed IntPredicate
returns
true
.
This method provides a means to repeat an operation multiple times and in sequential programming is similar to:
int i = 0;
do {
resultOfThisCompletable();
} while (shouldRepeat.test(++i));
shouldRepeat
- IntPredicate
that given the repeat count determines if the operation should be
repeatedPublisher
that emits the value returned by the passed Supplier
everytime this
Completable
completes.public final Publisher<java.lang.Void> repeatWhen(java.util.function.IntFunction<? extends Completable> repeatWhen)
Completable
when it completes and the Completable
returned by the supplied
IntFunction
completes successfully. If the returned Completable
emits an error, the returned
Completable
emits an error.
This method provides a means to repeat an operation multiple times when in an asynchronous fashion and in sequential programming is similar to:
int i = 0;
while (true) {
resultOfThisCompletable();
try {
repeatWhen.apply(++i); // Either throws or completes normally
} catch (Throwable cause) {
break;
}
}
repeatWhen
- IntFunction
that given the repeat count returns a Completable
.
If this Completable
emits an error repeat is terminated, otherwise, original Completable
is
re-subscribed when this Completable
completes.Completable
that completes after all re-subscriptions completes.public final Completable beforeOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
onSubscribe
Consumer
argument before
CompletableSource.Subscriber.onSubscribe(Cancellable)
is called for CompletableSource.Subscriber
s of the returned
Completable
.onSubscribe
- Invoked before CompletableSource.Subscriber.onSubscribe(Cancellable)
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable beforeOnComplete(java.lang.Runnable onComplete)
onComplete
Runnable
argument before CompletableSource.Subscriber.onComplete()
is called for CompletableSource.Subscriber
s of the returned Completable
.
From a sequential programming point of view this method is roughly equivalent to the following:
resultOfThisCompletable();
onComplete.run();
nextOperation();
onComplete
- Invoked before CompletableSource.Subscriber.onComplete()
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable beforeOnError(java.util.function.Consumer<java.lang.Throwable> onError)
onError
Consumer
argument before
CompletableSource.Subscriber.onError(Throwable)
is called for CompletableSource.Subscriber
s of the returned Completable
.
From a sequential programming point of view this method is roughly equivalent to the following:
try {
resultOfThisCompletable();
} catch (Throwable cause) {
onError.accept(cause);
nextOperation(cause);
}
onError
- Invoked before CompletableSource.Subscriber.onError(Throwable)
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable beforeCancel(java.lang.Runnable onCancel)
onCancel
Runnable
argument before Cancellable.cancel()
is
called for Subscriptions of the returned Completable
.onCancel
- Invoked before Cancellable.cancel()
is called for Subscriptions of the
returned Completable
. MUST NOT throw.Completable
.public final Completable beforeFinally(java.lang.Runnable doFinally)
whenFinally
Runnable
argument before any of the following terminal
methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
CompletableSource.Subscriber
s of the returned Completable
.
try {
resultOfThisCompletable();
} finally {
whenFinally.run();
nextOperation(); // Maybe notifying of cancellation, or termination
}
doFinally
- Invoked before any of the following terminal methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable beforeSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
CompletableSource.Subscriber
(via the subscriberSupplier
argument) on each call to
subscribe and invokes all the CompletableSource.Subscriber
methods before the CompletableSource.Subscriber
s of the
returned Completable
.subscriberSupplier
- Creates a new CompletableSource.Subscriber
on each call to subscribe and invokes all the
CompletableSource.Subscriber
methods before the CompletableSource.Subscriber
s of the returned Completable
.
CompletableSource.Subscriber
methods MUST NOT throw.Completable
.public final Completable afterOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
onSubscribe
Consumer
argument after
CompletableSource.Subscriber.onSubscribe(Cancellable)
is called for CompletableSource.Subscriber
s of the returned
Completable
.onSubscribe
- Invoked after CompletableSource.Subscriber.onSubscribe(Cancellable)
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable whenOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
onSubscribe
Consumer
argument when
CompletableSource.Subscriber.onSubscribe(Cancellable)
is called for CompletableSource.Subscriber
s of the returned
Completable
.
The order in which onSubscribe
will be invoked relative to
CompletableSource.Subscriber.onSubscribe(Cancellable)
is undefined. If you need strict ordering see
beforeOnSubscribe(Consumer)
and afterOnSubscribe(Consumer)
.
onSubscribe
- Invoked when CompletableSource.Subscriber.onSubscribe(Cancellable)
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.beforeOnSubscribe(Consumer)
,
afterOnSubscribe(Consumer)
public final Completable afterOnComplete(java.lang.Runnable onComplete)
onComplete
Runnable
argument after CompletableSource.Subscriber.onComplete()
is called for CompletableSource.Subscriber
s of the returned Completable
.
From a sequential programming point of view this method is roughly equivalent to the following:
resultOfThisCompletable();
nextOperation();
onComplete.run();
onComplete
- Invoked after CompletableSource.Subscriber.onComplete()
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable afterOnError(java.util.function.Consumer<java.lang.Throwable> onError)
onError
Consumer
argument after
CompletableSource.Subscriber.onError(Throwable)
is called for CompletableSource.Subscriber
s of the returned Completable
.
From a sequential programming point of view this method is roughly equivalent to the following:
try {
resultOfThisCompletable();
} catch (Throwable cause) {
nextOperation(cause);
onError.accept(cause);
}
onError
- Invoked after CompletableSource.Subscriber.onError(Throwable)
is called for
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable afterCancel(java.lang.Runnable onCancel)
onCancel
Runnable
argument after Cancellable.cancel()
is
called for Subscriptions of the returned Completable
.onCancel
- Invoked after Cancellable.cancel()
is called for Subscriptions of the
returned Completable
. MUST NOT throw.Completable
.public final Completable afterFinally(java.lang.Runnable doFinally)
whenFinally
Runnable
argument after any of the following terminal
methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
CompletableSource.Subscriber
s of the returned Completable
.
From a sequential programming point of view this method is roughly equivalent to the following:
try {
resultOfThisCompletable();
} finally {
nextOperation(); // Maybe notifying of cancellation, or termination
whenFinally.run();
}
doFinally
- Invoked after any of the following terminal methods are called:
CompletableSource.Subscriber.onComplete()
CompletableSource.Subscriber.onError(Throwable)
Cancellable.cancel()
CompletableSource.Subscriber
s of the returned Completable
. MUST NOT throw.Completable
.public final Completable afterSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
CompletableSource.Subscriber
(via the subscriberSupplier
argument) on each call to
subscribe and invokes all the CompletableSource.Subscriber
methods after the CompletableSource.Subscriber
s of the
returned Completable
.subscriberSupplier
- Creates a new CompletableSource.Subscriber
on each call to subscribe and invokes all the
CompletableSource.Subscriber
methods after the CompletableSource.Subscriber
s of the returned Completable
.
CompletableSource.Subscriber
methods MUST NOT throw.Completable
.public final Completable whenSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
CompletableSource.Subscriber
(via the subscriberSupplier
argument) for each new subscribe and
invokes methods on that CompletableSource.Subscriber
when the corresponding methods are called for CompletableSource.Subscriber
s of
the returned Publisher
.subscriberSupplier
- Creates a new CompletableSource.Subscriber
for each new subscribe and invokes methods on that
CompletableSource.Subscriber
when the corresponding methods are called for CompletableSource.Subscriber
s of the returned
Publisher
. CompletableSource.Subscriber
methods MUST NOT throw.Completable
.public final Completable liftSync(CompletableOperator operator)
Returns a Completable
which will wrap the CompletableSource.Subscriber
using the provided operator
argument
before subscribing to this Completable
.
Completable<X> pub = ...;
pub.map(..) // A
.liftSync(original -> modified)
.afterFinally(..) // B
The original -> modified
"operator" MUST be "synchronous" in that it does not interact
with the original CompletableSource.Subscriber
from outside the modified CompletableSource.Subscriber
or Cancellable
threads. That is to say this operator will not impact the Executor
constraints already in place between
A and B above. If you need asynchronous behavior, or are unsure, see
liftAsync(CompletableOperator)
.operator
- The custom operator logic. The input is the "original" CompletableSource.Subscriber
to this
Completable
and the return is the "modified" CompletableSource.Subscriber
that provides custom operator business
logic.Completable
that when subscribed, the operator
argument will be used to wrap the
CompletableSource.Subscriber
before subscribing to this Completable
.liftAsync(CompletableOperator)
public final Completable liftAsync(CompletableOperator operator)
Returns a Completable
which will wrap the CompletableSource.Subscriber
using the provided operator
argument
before subscribing to this Completable
.
Publisher<X> pub = ...;
pub.map(..) // A
.liftAsync(original -> modified)
.afterFinally(..) // B
The original -> modified
"operator" MAY be "asynchronous" in that it may interact with the original
CompletableSource.Subscriber
from outside the modified CompletableSource.Subscriber
or Cancellable
threads. More
specifically:
CompletableSource.Subscriber
invocations going "downstream" (i.e. from A to B above) MAY be
offloaded via an Executor
Cancellable
invocations going "upstream" (i.e. from B to A above) MAY be
offloaded via an Executor
operator
- The custom operator logic. The input is the "original" CompletableSource.Subscriber
to this
Completable
and the return is the "modified" CompletableSource.Subscriber
that provides custom operator business
logic.Completable
that when subscribed, the operator
argument will be used to wrap the
CompletableSource.Subscriber
before subscribing to this Completable
.liftSync(CompletableOperator)
public final Completable publishOn(Executor executor)
Completable
that will use the passed Executor
to invoke all CompletableSource.Subscriber
methods.
This method does not override preceding Executor
s, if any, specified for this
Completable
. Only subsequent operations, if any, added in this execution chain will use this
Executor
. If such an override is required, publishOnOverride(Executor)
can be used.executor
- Executor
to use.Completable
that will use the passed Executor
to invoke all methods on the
CompletableSource.Subscriber
.public final Completable publishOnOverride(Executor executor)
Completable
that will use the passed Executor
to invoke all CompletableSource.Subscriber
methods.
This method overrides preceding Executor
s, if any, specified for this
Completable
.
That is to say preceding and subsequent operations for this execution chain will use this Executor
.
If such an override is not required, publishOn(Executor)
can be used.executor
- Executor
to use.Completable
that will use the passed Executor
to invoke all methods of
CompletableSource.Subscriber
, Cancellable
and handleSubscribe(CompletableSource.Subscriber)
both for the
returned Completable
as well as this
Completable
.public final Completable subscribeOn(Executor executor)
Completable
that will use the passed Executor
to invoke the following methods:
Cancellable
methods.handleSubscribe(CompletableSource.Subscriber)
method.Executor
s, if any, specified for this
Completable
. Only subsequent operations, if any, added in this execution chain will use this
Executor
. If such an override is required, subscribeOnOverride(Executor)
can be used.executor
- Executor
to use.Completable
that will use the passed Executor
to invoke all methods of
Cancellable
and handleSubscribe(CompletableSource.Subscriber)
.public final Completable subscribeOnOverride(Executor executor)
Completable
that will use the passed Executor
to invoke the following methods:
Cancellable
methods.handleSubscribe(CompletableSource.Subscriber)
method.Executor
s, if any, specified for this
Completable
.
That is to say preceding and subsequent operations for this execution chain will use this Executor
.
If such an override is not required, subscribeOn(Executor)
can be used.executor
- Executor
to use.Completable
that will use the passed Executor
to invoke all methods of
Cancellable
and handleSubscribe(CompletableSource.Subscriber)
both for the returned
Completable
as well as this
Completable
.public final Completable publishAndSubscribeOn(Executor executor)
Completable
that will use the passed Executor
to invoke the following methods:
CompletableSource.Subscriber
methods.Cancellable
methods.handleSubscribe(CompletableSource.Subscriber)
method.Executor
s, if any, specified for this
Completable
. Only subsequent operations, if any, added in this execution chain will use this
Executor
. If such an override is required, publishAndSubscribeOnOverride(Executor)
can be used.executor
- Executor
to use.Completable
that will use the passed Executor
to invoke all methods
CompletableSource.Subscriber
, Cancellable
and handleSubscribe(CompletableSource.Subscriber)
.public final Completable publishAndSubscribeOnOverride(Executor executor)
Completable
that will use the passed Executor
to invoke the following methods:
CompletableSource.Subscriber
methods.Cancellable
methods.handleSubscribe(CompletableSource.Subscriber)
method.Executor
s, if any, specified for this
Completable
.
That is to say preceding and subsequent operations for this execution chain will use this Executor
.
If such an override is not required, publishAndSubscribeOn(Executor)
can be used.executor
- Executor
to use.Completable
that will use the passed Executor
to invoke all methods of
CompletableSource.Subscriber
, Cancellable
and handleSubscribe(CompletableSource.Subscriber)
both for the
returned Completable
as well as this
Completable
.public final Completable subscribeShareContext()
Completable
is subscribed to, the AsyncContext
will be shared
instead of making a copy
.
This operator only impacts behavior if the returned Completable
is subscribed directly after this
operator, that means this must be the "last operator" in the chain for this to have an impact.
Completable
that will share the AsyncContext
instead of making a
copy
when subscribed to.public final <T> Publisher<T> toPublisher()
Completable
to a Publisher
.
No PublisherSource.Subscriber.onNext(Object)
signals will be delivered to the
returned Publisher
. Only terminal signals will be delivered. If you need more control you should consider
using concat(Publisher)
.
T
- The value type of the resulting Publisher
.Publisher
that mirrors the terminal signal from this Completable
.public final Single<java.lang.Void> toSingle()
Completable
to a Single
.Single
that mirrors the terminal signal from this Completable
.public final java.util.concurrent.CompletionStage<java.lang.Void> toCompletionStage()
Completable
to a CompletionStage
.CompletionStage
that mirrors the terminal signal from this Completable
.public final java.util.concurrent.Future<java.lang.Void> toFuture()
Completable
to a Future
.Future
that mirrors the terminal signal from this Completable
.protected final void subscribeInternal(CompletableSource.Subscriber subscriber)
CompletableSource.subscribe(Subscriber)
which can be used by
different implementations to subscribe.subscriber
- CompletableSource.Subscriber
to subscribe for the result.public final Cancellable subscribe()
Completable
and log any CompletableSource.Subscriber.onError(Throwable)
.Cancellable
used to invoke Cancellable.cancel()
on the parameter of
CompletableSource.Subscriber.onSubscribe(Cancellable)
for this Completable
.public final Cancellable subscribe(java.lang.Runnable onComplete)
Completable
and log any CompletableSource.Subscriber.onError(Throwable)
. Passed Runnable
is invoked when this Completable
terminates successfully.onComplete
- Runnable
to invoke when this Completable
terminates successfully.Cancellable
used to invoke Cancellable.cancel()
on the parameter of
CompletableSource.Subscriber.onSubscribe(Cancellable)
for this Completable
.protected abstract void handleSubscribe(CompletableSource.Subscriber subscriber)
Completable
.
This method is invoked internally by Completable
for every call to the
subscribeInternal(CompletableSource.Subscriber)
method.
subscriber
- the subscriber.public static Completable completed()
Completable
.Completable
.public static Completable fromRunnable(java.lang.Runnable runnable)
Completable
which when subscribed will invoke Runnable.run()
on the passed
Runnable
and emit the value returned by that invocation from the returned Completable
. Any error
emitted by the Runnable
will terminate the returned Completable
with the same error.
Blocking inside Runnable.run()
will in turn block the subscribe call to the returned Completable
.
If this behavior is undesirable then the returned Completable
should be offloaded using one of the
operators that offloads the subscribe call (eg: subscribeOn(Executor)
,
publishAndSubscribeOn(Executor)
).
runnable
- Runnable
which is invoked before completion.Completable
.public static Completable failed(java.lang.Throwable cause)
Completable
.cause
- error that the returned Completable
completes with.Completable
.public static Completable never()
Completable
that never terminates.Completable
.public static Completable defer(java.util.function.Supplier<? extends Completable> completableSupplier)
Completable
till it is subscribed to.completableSupplier
- Supplier
to create a new Completable
for every call to
subscribeInternal(CompletableSource.Subscriber)
to the returned Completable
.Completable
that creates a new Completable
using completableFactory
for every call to subscribeInternal(CompletableSource.Subscriber)
and forwards
the termination signal from the newly created Completable
to its CompletableSource.Subscriber
.public static Completable fromFuture(java.util.concurrent.Future<?> future)
Future
to a Completable
via Future.get()
.
Note that because Future
only presents blocking APIs to extract the result, so the process of getting the
results will block. The caller of subscribeInternal(CompletableSource.Subscriber)
is responsible for
offloading if necessary, and also offloading if Cancellable.cancel()
will be called if this operation may
block.
To apply a timeout see idleTimeout(long, TimeUnit)
and related methods.
future
- The Future
to convert.Completable
that derives results from Future
.idleTimeout(long, TimeUnit)
public static Completable fromStage(java.util.concurrent.CompletionStage<?> stage)
CompletionStage
to a Completable
.
A best effort is made to propagate Cancellable.cancel()
to the CompletionStage
. Cancellation for
CompletionStage
implementations will result in exceptional completion and invoke user
callbacks. If there is any blocking code involved in the cancellation process (including invoking user callbacks)
you should investigate if using an Executor
is appropriate.
stage
- The CompletionStage
to convert.Completable
that derives results from CompletionStage
.public static Completable mergeAll(java.lang.Iterable<? extends Completable> completables)
Completable
that terminates when all the passed Completable
terminate.
This will actively subscribe to a default number of Completable
s concurrently, in order to alter the
defaults, mergeAll(Iterable, int)
.
If any of the Completable
s terminate with an error, returned Completable
will immediately
terminate with that error. In such a case, any in-progress Completable
s will be cancelled. In order to
delay error termination use mergeAllDelayError(Iterable)
.
From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
ft.get();
}
completables
- Iterable
of Completable
s, results of which are to be collected.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAll(Completable... completables)
Completable
that terminates when all the passed Completable
terminate.
This will actively subscribe to a default number of Completable
s concurrently, in order to alter the
defaults, mergeAll(int, Completable...)
should be used.
If any of the Completable
s terminate with an error, returned Completable
will immediately
terminate with that error. In such a case, any in-progress Completable
s will be cancelled.
In order to delay error termination use mergeAllDelayError(Completable...)
.
From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
ft.get();
}
completables
- Completable
s, results of which are to be collected.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAll(java.lang.Iterable<? extends Completable> completables, int maxConcurrency)
Completable
that terminates when all the passed Completable
terminate.
If any of the Completable
s terminate with an error, returned Completable
will immediately
terminate with that error. In such a case, any in-progress Completable
s will be cancelled. In order to
delay error termination use mergeAllDelayError(Iterable, int)
.
From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
ft.get();
}
completables
- Iterable
of Completable
s, results of which are to be collected.maxConcurrency
- Maximum number of Completable
s that will be active at any point in time.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAll(int maxConcurrency, Completable... completables)
Completable
that terminates when all the passed Completable
terminate.
If any of the Completable
s terminate with an error, returned Completable
will immediately
terminate with that error. In such a case, any in-progress Completable
s will be cancelled.
In order to delay error termination use mergeAllDelayError(int, Completable...)
.
From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
ft.get();
}
maxConcurrency
- Maximum number of Completable
s that will be active at any point in time.completables
- Completable
s, results of which are to be collected.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAllDelayError(java.lang.Iterable<? extends Completable> completables)
Completable
that terminates when all the passed Completable
terminate.
This will actively subscribe to a default number of Completable
s concurrently, in order to alter the
defaults, mergeAllDelayError(Iterable, int)
should be used.
If any of the Completable
s terminate with an error, returned Completable
will wait for
termination till all the other Completable
s have been subscribed and terminated. If it is expected for
the returned Completable
to terminate on the first failing Completable
,
mergeAll(Iterable)
should be used.
From a sequential programming point of view this method is roughly equivalent to the following:
List<Throwable> errors = ...; // assume this is thread safe
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
try {
ft.get();
} catch(Throwable t) {
errors.add(t);
}
}
if (errors.isEmpty()) {
return;
}
createAndThrowACompositeException(errors);
completables
- Iterable
of Completable
s, results of which are to be collected.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAllDelayError(Completable... completables)
Completable
that terminates when all the passed Completable
terminate.
This will actively subscribe to a limited number of Single
s concurrently, in order to alter the defaults,
mergeAll(int, Completable...)
should be used.
If any of the Single
s terminate with an error, returned Single
will wait for termination till all
the other Single
s have been subscribed and terminated. If it is expected for the returned Single
to terminate on the first failing Single
, mergeAll(Completable...)
should be used.
From a sequential programming point of view this method is roughly equivalent to the following:
List<Throwable> errors = ...; // assume this is thread safe
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
try {
ft.get();
} catch(Throwable t) {
errors.add(t);
}
}
if (errors.isEmpty()) {
return;
}
createAndThrowACompositeException(errors);
completables
- Completable
s, results of which are to be collected.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAllDelayError(java.lang.Iterable<? extends Completable> completables, int maxConcurrency)
Completable
that terminates when all the passed Completable
terminate.
If any of the Single
s terminate with an error, returned Single
will wait for termination till all
the other Single
s have been subscribed and terminated. If it is expected for the returned Single
to terminate on the first failing Single
, mergeAll(Iterable, int)
should be used.
From a sequential programming point of view this method is roughly equivalent to the following:
List<Throwable> errors = ...; // assume this is thread safe
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
try {
ft.get();
} catch(Throwable t) {
errors.add(t);
}
}
if (errors.isEmpty()) {
return;
}
createAndThrowACompositeException(errors);
completables
- Iterable
of Completable
s, results of which are to be collected.maxConcurrency
- Maximum number of Completable
s that will be active at any point in time.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.public static Completable mergeAllDelayError(int maxConcurrency, Completable... completables)
Completable
that terminates when all the passed Completable
terminate.
If any of the Single
s terminate with an error, returned Single
will wait for termination till all
the other Single
s have been subscribed and terminated. If it is expected for the returned Single
to terminate on the first failing Single
, mergeAll(Iterable, int)
should be used.
From a sequential programming point of view this method is roughly equivalent to the following:
List<Throwable> errors = ...; // assume this is thread safe
for (Future<Void> ft: futures) { // Provided Futures (analogous to the Completables here)
// This is an approximation, this operator does not provide any ordering guarantees for the results.
try {
ft.get();
} catch(Throwable t) {
errors.add(t);
}
}
if (errors.isEmpty()) {
return;
}
createAndThrowACompositeException(errors);
maxConcurrency
- Maximum number of Completable
s that will be active at any point in time.completables
- Completable
s, results of which are to be collected.Completable
that terminates successfully if all the provided Completable
s have
terminated successfully or any one of them has terminated with a failure.