Class Completable
- java.lang.Object
-
- io.servicetalk.concurrent.api.Completable
-
- Direct Known Subclasses:
LegacyTestCompletable,RunnableCompletable,SubscribableCompletable,TestCompletable
public abstract class Completable extends java.lang.ObjectAn asynchronous computation that does not emit any data. It just completes or emits an error.How to subscribe?
This class does not provide a way to subscribe using aCompletableSource.Subscriberas 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 asource adaptercan be used to convert to aCompletableSource.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCompletable()New instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CompletableafterCancel(java.lang.Runnable onCancel)Invokes theonCancelRunnableargument afterCancellable.cancel()is called for Subscriptions of the returnedCompletable.CompletableafterFinally(TerminalSignalConsumer doFinally)Invokes the corresponding method onafterFinallyTerminalSignalConsumerargument after any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()CompletableSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()for Subscriptions/CompletableSource.Subscribers of the returnedCompletable.CompletableafterFinally(java.lang.Runnable doFinally)Invokes thewhenFinallyRunnableargument after any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()for Subscriptions/CompletableSource.Subscribers of the returnedCompletable.CompletableafterOnComplete(java.lang.Runnable onComplete)Invokes theonCompleteRunnableargument afterCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable.CompletableafterOnError(java.util.function.Consumer<java.lang.Throwable> onError)Invokes theonErrorConsumerargument afterCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable.CompletableafterOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)Invokes theonSubscribeConsumerargument afterCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable.CompletableafterSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)Creates a newCompletableSource.Subscriber(via thesubscriberSupplierargument) on each call to subscribe and invokes all theCompletableSource.Subscribermethods after theCompletableSource.Subscribers of the returnedCompletable.static Completableamb(Completable... completables)Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.static Completableamb(java.lang.Iterable<Completable> completables)Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.CompletableambWith(Completable other)Creates a newCompletablethat terminates with the result (either success or error) of either thisCompletableor the passedotherCompletable, whichever terminates first.static CompletableanyOf(Completable... completables)Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.static CompletableanyOf(java.lang.Iterable<Completable> completables)Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.CompletablebeforeCancel(java.lang.Runnable onCancel)Invokes theonCancelRunnableargument beforeCancellable.cancel()is called for Subscriptions of the returnedCompletable.CompletablebeforeFinally(TerminalSignalConsumer doFinally)Invokes the corresponding method onbeforeFinallyTerminalSignalConsumerargument before any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()CompletableSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()for Subscriptions/CompletableSource.Subscribers of the returnedCompletable.CompletablebeforeFinally(java.lang.Runnable doFinally)Invokes thewhenFinallyRunnableargument before any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()for Subscriptions/CompletableSource.Subscribers of the returnedCompletable.CompletablebeforeOnComplete(java.lang.Runnable onComplete)Invokes theonCompleteRunnableargument beforeCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable.CompletablebeforeOnError(java.util.function.Consumer<java.lang.Throwable> onError)Invokes theonErrorConsumerargument beforeCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable.CompletablebeforeOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)Invokes theonSubscribeConsumerargument beforeCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable.CompletablebeforeSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)Creates a newCompletableSource.Subscriber(via thesubscriberSupplierargument) on each call to subscribe and invokes all theCompletableSource.Subscribermethods before theCompletableSource.Subscribers of the returnedCompletable.static Completablecompleted()Creates a realized completedCompletable.Completableconcat(Completable next)Once thisCompletableis terminated successfully, subscribe tonextCompletableand propagate its terminal signal to the returnedCompletable.<T> Publisher<T>concat(Publisher<? extends T> next)Once thisCompletableis terminated successfully, subscribe tonextPublisherand propagate all emissions to the returnedPublisher.<T> Single<T>concat(Single<? extends T> next)Once thisCompletableis terminated successfully, subscribe tonextSingleand propagate the result to the returnedSingle.static Completabledefer(java.util.function.Supplier<? extends Completable> completableSupplier)Defer creation of aCompletabletill it is subscribed to.static Completablefailed(java.lang.Throwable cause)Creates a realized failedCompletable.static CompletablefromFuture(java.util.concurrent.Future<?> future)static CompletablefromRunnable(java.lang.Runnable runnable)Creates aCompletablewhich when subscribed will invokeRunnable.run()on the passedRunnableand emit the value returned by that invocation from the returnedCompletable.static CompletablefromStage(java.util.concurrent.CompletionStage<?> stage)Convert from aCompletionStageto aCompletable.protected abstract voidhandleSubscribe(CompletableSource.Subscriber subscriber)Handles a subscriber to thisCompletable.CompletableidleTimeout(long duration, java.util.concurrent.TimeUnit unit)Deprecated.CompletableidleTimeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)Deprecated.CompletableidleTimeout(java.time.Duration duration)Deprecated.Usetimeout(Duration).CompletableidleTimeout(java.time.Duration duration, Executor timeoutExecutor)Deprecated.CompletableliftAsync(CompletableOperator operator)This method requires advanced knowledge of building operators.CompletableliftSync(CompletableOperator operator)This method requires advanced knowledge of building operators.Completablemerge(Completable other)Merges thisCompletablewith theotherCompletableso that the resultingCompletableterminates successfully when both of these complete or either terminates with an error.Completablemerge(Completable... other)Merges thisCompletablewith theotherCompletables so that the resultingCompletableterminates successfully when all of these complete or any one terminates with an error.<T> Publisher<T>merge(Publisher<? extends T> mergeWith)Merges the passedPublisherwith thisCompletable.Completablemerge(java.lang.Iterable<? extends Completable> other)Merges thisCompletablewith theotherCompletables so that the resultingCompletableterminates successfully when all of these complete or terminates with an error when any one terminates with an error.static CompletablemergeAll(int maxConcurrency, Completable... completables)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAll(Completable... completables)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAll(java.lang.Iterable<? extends Completable> completables)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAll(java.lang.Iterable<? extends Completable> completables, int maxConcurrency)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAllDelayError(int maxConcurrency, Completable... completables)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAllDelayError(Completable... completables)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAllDelayError(java.lang.Iterable<? extends Completable> completables)Returns aCompletablethat terminates when all the passedCompletableterminate.static CompletablemergeAllDelayError(java.lang.Iterable<? extends Completable> completables, int maxConcurrency)Returns aCompletablethat terminates when all the passedCompletableterminate.CompletablemergeDelayError(Completable other)Merges thisCompletablewith theotherCompletable, and delays error notification until all involvedCompletables terminate.CompletablemergeDelayError(Completable... other)Merges thisCompletablewith theotherCompletables, and delays error notification until all involvedCompletables terminate.<T> Publisher<T>mergeDelayError(Publisher<? extends T> mergeWith)Merges the passedPublisherwith thisCompletable.CompletablemergeDelayError(java.lang.Iterable<? extends Completable> other)Merges thisCompletablewith theotherCompletables, and delays error notification until all involvedCompletables terminate.static Completablenever()Creates aCompletablethat never terminates.CompletableonErrorComplete()Transform errors emitted on thisCompletableinto aCompletableSource.Subscriber.onComplete()signal (e.g.<E extends java.lang.Throwable>
CompletableonErrorComplete(java.lang.Class<E> type)Transform errors emitted on thisCompletablewhich matchtypeinto aCompletableSource.Subscriber.onComplete()signal (e.g.CompletableonErrorComplete(java.util.function.Predicate<? super java.lang.Throwable> predicate)Transform errors emitted on thisCompletablewhich matchpredicateinto aCompletableSource.Subscriber.onComplete()signal (e.g.<E extends java.lang.Throwable>
CompletableonErrorMap(java.lang.Class<E> type, java.util.function.Function<? super E,? extends java.lang.Throwable> mapper)Transform errors emitted on thisCompletablewhich matchtypeinto a different error.CompletableonErrorMap(java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)Transform errors emitted on thisCompletableinto a different error.CompletableonErrorMap(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)Transform errors emitted on thisCompletablewhich matchpredicateinto a different error.<E extends java.lang.Throwable>
CompletableonErrorResume(java.lang.Class<E> type, java.util.function.Function<? super E,? extends Completable> nextFactory)Recover from errors emitted by thisCompletablewhich matchtypeby using anotherCompletableprovided by the passednextFactory.CompletableonErrorResume(java.util.function.Function<? super java.lang.Throwable,? extends Completable> nextFactory)Recover from any error emitted by thisCompletableby using anotherCompletableprovided by the passednextFactory.CompletableonErrorResume(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends Completable> nextFactory)Recover from errors emitted by thisCompletablewhich matchpredicateby using anotherCompletableprovided by the passednextFactory.CompletablepublishAndSubscribeOn(Executor executor)Creates a newCompletablethat will use the passedExecutorto invoke the following methods: AllCompletableSource.Subscribermethods. AllCancellablemethods. ThehandleSubscribe(CompletableSource.Subscriber)method. This method does not override precedingExecutors, if any, specified forthisCompletable.CompletablepublishAndSubscribeOnOverride(Executor executor)Creates a newCompletablethat will use the passedExecutorto invoke the following methods: AllCompletableSource.Subscribermethods. AllCancellablemethods. ThehandleSubscribe(CompletableSource.Subscriber)method. This method overrides precedingExecutors, if any, specified forthisCompletable.CompletablepublishOn(Executor executor)Creates a newCompletablethat will use the passedExecutorto invoke allCompletableSource.Subscribermethods.CompletablepublishOnOverride(Executor executor)Creates a newCompletablethat will use the passedExecutorto invoke allCompletableSource.Subscribermethods.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 thisCompletablewhen it completes and theCompletablereturned by the suppliedIntFunctioncompletes successfully.Completableretry(BiIntPredicate<java.lang.Throwable> shouldRetry)Re-subscribes to thisCompletableif an error is emitted and the passedBiIntPredicatereturnstrue.CompletableretryWhen(BiIntFunction<java.lang.Throwable,? extends Completable> retryWhen)Re-subscribes to thisCompletableif an error is emitted and theCompletablereturned by the suppliedBiIntFunctioncompletes successfully.Cancellablesubscribe()Subscribe to thisCompletableand log anyCompletableSource.Subscriber.onError(Throwable).Cancellablesubscribe(java.lang.Runnable onComplete)Subscribe to thisCompletableand log anyCompletableSource.Subscriber.onError(Throwable).protected voidsubscribeInternal(CompletableSource.Subscriber subscriber)A internal subscribe method similar toCompletableSource.subscribe(Subscriber)which can be used by different implementations to subscribe.CompletablesubscribeOn(Executor executor)Creates a newCompletablethat will use the passedExecutorto invoke the following methods: AllCancellablemethods. ThehandleSubscribe(CompletableSource.Subscriber)method. This method does not override precedingExecutors, if any, specified forthisCompletable.CompletablesubscribeOnOverride(Executor executor)Creates a newCompletablethat will use the passedExecutorto invoke the following methods: AllCancellablemethods. ThehandleSubscribe(CompletableSource.Subscriber)method. This method overrides precedingExecutors, if any, specified forthisCompletable.CompletablesubscribeShareContext()Signifies that when the returnedCompletableis subscribed to, theAsyncContextwill be shared instead of making acopy.Completabletimeout(long duration, java.util.concurrent.TimeUnit unit)Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination.Completabletimeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination.Completabletimeout(java.time.Duration duration)Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination.Completabletimeout(java.time.Duration duration, Executor timeoutExecutor)Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination.java.util.concurrent.CompletionStage<java.lang.Void>toCompletionStage()Converts thisCompletableto aCompletionStage.java.util.concurrent.Future<java.lang.Void>toFuture()Converts thisCompletableto aFuture.<T> Publisher<T>toPublisher()Converts thisCompletableto aPublisher.Single<java.lang.Void>toSingle()Converts thisCompletableto aSingle.CompletablewhenCancel(java.lang.Runnable onCancel)Invokes theonCancelRunnableargument whenCancellable.cancel()is called for Subscriptions of the returnedCompletable.CompletablewhenFinally(TerminalSignalConsumer doFinally)Invokes the corresponding method onwhenFinallyTerminalSignalConsumerargument when any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()CompletableSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()for Subscriptions/CompletableSource.Subscribers of the returnedCompletable.CompletablewhenFinally(java.lang.Runnable doFinally)Invokes thewhenFinallyRunnableargument exactly once, when any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()for Subscriptions/CompletableSource.Subscribers of the returnedCompletable.CompletablewhenOnComplete(java.lang.Runnable onComplete)Invokes theonCompleteRunnableargument whenCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable.CompletablewhenOnError(java.util.function.Consumer<java.lang.Throwable> onError)Invokes theonErrorConsumerargument whenCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable.CompletablewhenOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)Invokes theonSubscribeConsumerargument whenCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable.CompletablewhenSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)Creates a newCompletableSource.Subscriber(via thesubscriberSupplierargument) for each new subscribe and invokes methods on thatCompletableSource.Subscriberwhen the corresponding methods are called forCompletableSource.Subscribers of the returnedPublisher.
-
-
-
Method Detail
-
onErrorComplete
public final Completable onErrorComplete()
Transform errors emitted on thisCompletableinto aCompletableSource.Subscriber.onComplete()signal (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
try { resultOfThisCompletable(); } catch (Throwable cause) { // ignored }- Returns:
- A
Completablewhich transform errors emitted on thisCompletableinto aCompletableSource.Subscriber.onComplete()signal (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorComplete
public final <E extends java.lang.Throwable> Completable onErrorComplete(java.lang.Class<E> type)
Transform errors emitted on thisCompletablewhich matchtypeinto aCompletableSource.Subscriber.onComplete()signal (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
try { resultOfThisCompletable(); } catch (Throwable cause) { if (!type.isInstance(cause)) { throw cause; } }- Type Parameters:
E- TheThrowabletype.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.- Returns:
- A
Completablewhich transform errors emitted on thisCompletablewhich matchtypeinto aCompletableSource.Subscriber.onComplete()signal (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorComplete
public final Completable onErrorComplete(java.util.function.Predicate<? super java.lang.Throwable> predicate)
Transform errors emitted on thisCompletablewhich matchpredicateinto aCompletableSource.Subscriber.onComplete()signal (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
try { resultOfThisCompletable(); } catch (Throwable cause) { if (!predicate.test(cause)) { throw cause; } }- Parameters:
predicate- returnstrueif theThrowableshould be transformed to andCompletableSource.Subscriber.onComplete()signal. Returnsfalseto propagate the error.- Returns:
- A
Completablewhich transform errors emitted on thisCompletablewhich matchpredicateinto aCompletableSource.Subscriber.onComplete()signal (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorMap
public final Completable onErrorMap(java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)
Transform errors emitted on thisCompletableinto a different error.This method provides a data transformation in sequential programming similar to:
try { resultOfThisCompletable(); } catch (Throwable cause) { throw mapper.apply(cause); }- Parameters:
mapper- returns the error used to terminate the returnedCompletable.- Returns:
- A
Completablewhich transform errors emitted on thisCompletableinto a different error. - See Also:
- ReactiveX catch operator.
-
onErrorMap
public final <E extends java.lang.Throwable> Completable onErrorMap(java.lang.Class<E> type, java.util.function.Function<? super E,? extends java.lang.Throwable> mapper)
Transform errors emitted on thisCompletablewhich matchtypeinto a different error.This method provides a data transformation in sequential programming similar to:
try { resultOfThisCompletable(); } catch (Throwable cause) { if (type.isInstance(cause)) { throw mapper.apply(cause); } else { throw cause; } }- Type Parameters:
E- The type ofThrowableto transform.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.mapper- returns the error used to terminate the returnedCompletable.- Returns:
- A
Completablewhich transform errors emitted on thisCompletableinto a different error. - See Also:
- ReactiveX catch operator.
-
onErrorMap
public final Completable onErrorMap(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)
Transform errors emitted on thisCompletablewhich matchpredicateinto a different error.This method provides a data transformation in sequential programming similar to:
try { resultOfThisCompletable(); } catch (Throwable cause) { if (predicate.test(cause)) { throw mapper.apply(cause); } else { throw cause; } }- Parameters:
predicate- returnstrueif theThrowableshould be transformed viamapper. Returnsfalseto propagate the original error.mapper- returns the error used to terminate the returnedCompletable.- Returns:
- A
Completablewhich transform errors emitted on thisCompletableinto a different error. - See Also:
- ReactiveX catch operator.
-
onErrorResume
public final Completable onErrorResume(java.util.function.Function<? super java.lang.Throwable,? extends Completable> nextFactory)
Recover from any error emitted by thisCompletableby using anotherCompletableprovided by the passednextFactory.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); }- Parameters:
nextFactory- Returns the nextCompletable, if thisCompletableemits an error.- Returns:
- A
Completablethat recovers from an error from thisCompletableby using anotherCompletableprovided by the passednextFactory.
-
onErrorResume
public final <E extends java.lang.Throwable> Completable onErrorResume(java.lang.Class<E> type, java.util.function.Function<? super E,? extends Completable> nextFactory)
Recover from errors emitted by thisCompletablewhich matchtypeby using anotherCompletableprovided by the passednextFactory.This method provides similar capabilities to a try/catch block in sequential programming:
try { resultOfThisCompletable(); } catch (Throwable cause) { if (type.isInstance(cause)) { // Note nextFactory returning a error Completable is like re-throwing (nextFactory shouldn't throw). results = nextFactory.apply(cause); } else { throw cause; } }- Type Parameters:
E- The type ofThrowableto transform.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.nextFactory- Returns the nextCompletable, when thisCompletableemits an error.- Returns:
- A
Completablethat recovers from an error from thisPublisherby using anotherCompletableprovided by the passednextFactory. - See Also:
- ReactiveX catch operator.
-
onErrorResume
public final Completable onErrorResume(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends Completable> nextFactory)
Recover from errors emitted by thisCompletablewhich matchpredicateby using anotherCompletableprovided by the passednextFactory.This method provides similar capabilities to a try/catch block in sequential programming:
try { resultOfThisCompletable(); } catch (Throwable cause) { if (predicate.test(cause)) { // Note that nextFactory returning a error Publisher is like re-throwing (nextFactory shouldn't throw). results = nextFactory.apply(cause); } else { throw cause; } }- Parameters:
predicate- returnstrueif theThrowableshould be transformed vianextFactory. Returnsfalseto propagate the original error.nextFactory- Returns the nextCompletable, when thisCompletableemits an error.- Returns:
- A
Completablethat recovers from an error from thisCompletableby using anotherCompletableprovided by the passednextFactory. - See Also:
- ReactiveX catch operator.
-
whenOnComplete
public final Completable whenOnComplete(java.lang.Runnable onComplete)
Invokes theonCompleteRunnableargument whenCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable.The order in which
onCompletewill be invoked relative toCompletableSource.Subscriber.onComplete()is undefined. If you need strict ordering seebeforeOnComplete(Runnable)andafterOnComplete(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();- Parameters:
onComplete- Invoked whenCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable. - See Also:
beforeOnComplete(Runnable),afterOnComplete(Runnable)
-
whenOnError
public final Completable whenOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes theonErrorConsumerargument whenCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable.The order in which
onErrorwill be invoked relative toCompletableSource.Subscriber.onError(Throwable)is undefined. If you need strict ordering seebeforeOnError(Consumer)andafterOnError(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); }- Parameters:
onError- Invoked whenCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable. - See Also:
beforeOnError(Consumer),afterOnError(Consumer)
-
whenFinally
public final Completable whenFinally(java.lang.Runnable doFinally)
Invokes thewhenFinallyRunnableargument exactly once, when any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()
CompletableSource.Subscribers of the returnedCompletable.The order in which
whenFinallywill be invoked relative to the above methods is undefined. If you need strict ordering seebeforeFinally(Runnable)andafterFinally(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 doFinally.run(); }- Parameters:
doFinally- Invoked exactly once, when any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()
CompletableSource.Subscribers of the returnedCompletableMUST NOT throw.- Returns:
- The new
Completable. - See Also:
beforeFinally(Runnable),afterFinally(Runnable)
-
whenFinally
public final Completable whenFinally(TerminalSignalConsumer doFinally)
Invokes the corresponding method onwhenFinallyTerminalSignalConsumerargument when any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()CompletableSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()
CompletableSource.Subscribers of the returnedCompletable.The order in which
whenFinallywill be invoked relative to the above methods is undefined. If you need strict ordering seebeforeFinally(TerminalSignalConsumer)andafterFinally(TerminalSignalConsumer).From a sequential programming point of view this method is roughly equivalent to the following:
try { resultOfThisCompletable(); } catch(Throwable t) { // NOTE: The order of operations here is not guaranteed by this method! nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onError(t); return; } // NOTE: The order of operations here is not guaranteed by this method! nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onComplete();- Parameters:
doFinally- For each subscribe of the returnedCompletable, at most one method of thisTerminalSignalConsumerwill be invoked.- Returns:
- The new
Completable. - See Also:
beforeFinally(TerminalSignalConsumer),afterFinally(TerminalSignalConsumer)
-
whenCancel
public final Completable whenCancel(java.lang.Runnable onCancel)
Invokes theonCancelRunnableargument whenCancellable.cancel()is called for Subscriptions of the returnedCompletable.The order in which
whenFinallywill be invoked relative toCancellable.cancel()is undefined. If you need strict ordering seebeforeCancel(Runnable)andafterCancel(Runnable).- Parameters:
onCancel- Invoked whenCancellable.cancel()is called for Subscriptions of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable. - See Also:
beforeCancel(Runnable),afterCancel(Runnable)
-
idleTimeout
@Deprecated public final Completable idleTimeout(long duration, java.util.concurrent.TimeUnit unit)
Deprecated.Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().unit- The units forduration.- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
idleTimeout
@Deprecated public final Completable idleTimeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)
Deprecated.Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().unit- The units forduration.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
idleTimeout
@Deprecated public final Completable idleTimeout(java.time.Duration duration)
Deprecated.Usetimeout(Duration).Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
idleTimeout
@Deprecated public final Completable idleTimeout(java.time.Duration duration, Executor timeoutExecutor)
Deprecated.Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
timeout
public final Completable timeout(long duration, java.util.concurrent.TimeUnit unit)
Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().unit- The units forduration.- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
timeout
public final Completable timeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)
Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().unit- The units forduration.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
timeout
public final Completable timeout(java.time.Duration duration)
Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
timeout
public final Completable timeout(java.time.Duration duration, Executor timeoutExecutor)
Creates a newCompletablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedCompletableis subscribed.In the event of timeout any
CancellablefromCompletableSource.Subscriber.onSubscribe(Cancellable)will becancelledand the associatedCompletableSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse beforeCompletableSource.Subscriber.onComplete().timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Completablethat will mimic the signals of thisCompletablebut will terminate with aTimeoutExceptionif timedurationelapses beforeCompletableSource.Subscriber.onComplete(). - See Also:
- ReactiveX timeout operator.
-
concat
public final Completable concat(Completable next)
Once thisCompletableis terminated successfully, subscribe tonextCompletableand propagate its terminal signal to the returnedCompletable. Any error from thisCompletableornextCompletableare propagated to the returnedCompletable.This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
resultOfThisCompletable(); nextCompletable();- Parameters:
next-Completableto subscribe after thisCompletableterminates successfully.- Returns:
- A
Completablethat emits the terminal signal ofnextCompletable, after thisCompletablehas terminated successfully.
-
concat
public final <T> Single<T> concat(Single<? extends T> next)
Once thisCompletableis terminated successfully, subscribe tonextSingleand propagate the result to the returnedSingle. Any error from thisCompletableornextSingleare propagated to the returnedSingle.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;- Type Parameters:
T- Type of result of the returnedSingle.- Parameters:
next-Singleto subscribe after thisCompletableterminates successfully.- Returns:
- A
Singlethat emits the result ofnextSingle, after thisCompletablehas terminated successfully.
-
concat
public final <T> Publisher<T> concat(Publisher<? extends T> next)
Once thisCompletableis terminated successfully, subscribe tonextPublisherand propagate all emissions to the returnedPublisher. Any error from thisCompletableornextPublisherare propagated to the returnedPublisher.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;- Type Parameters:
T- Type of objects emitted from the returnedPublisher.- Parameters:
next-Publisherto subscribe after thisCompletableterminates successfully.- Returns:
- A
Publisherthat emits all items emitted fromnextPublisher, after thisCompletablehas terminated successfully.
-
merge
public final Completable merge(Completable other)
Merges thisCompletablewith theotherCompletableso that the resultingCompletableterminates successfully when both of these complete or either 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())); futures.add(e.submit(() -> resultOfCompletable(other)); // 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. }- Parameters:
other-Completables to merge.- Returns:
Completablethat terminates successfully when this andotherCompletables complete or terminates with an error when either terminates with an error.
-
merge
public final Completable merge(Completable... other)
Merges thisCompletablewith theotherCompletables so that the resultingCompletableterminates successfully when all of these complete or 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. }- Parameters:
other-Completables to merge.- Returns:
Completablethat terminates successfully when this and allotherCompletables complete or terminates with an error when any one terminates with an error.
-
merge
public final Completable merge(java.lang.Iterable<? extends Completable> other)
Merges thisCompletablewith theotherCompletables so that the resultingCompletableterminates 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. }- Parameters:
other-Completables to merge.- Returns:
Completablethat terminates successfully when this and allotherCompletables complete or terminates with an error when any one terminates with an error.
-
merge
public final <T> Publisher<T> merge(Publisher<? extends T> mergeWith)
Merges the passedPublisherwith thisCompletable.The resulting
Publisheremits all items emitted by the passedPublisherand terminates successfully when both thisCompletableand the passedPublisherterminates successfully. It terminates with an error when any one of thisCompletableor passedPublisherterminates 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.- Type Parameters:
T- The value type of the resultingPublisher.- Parameters:
mergeWith- thePublisherto merge in- Returns:
Publisherthat emits all items emitted by the passedPublisherand terminates successfully when both thisCompletableand the passedPublisherterminates successfully. It terminates with an error when any one of thisCompletableor passedPublisherterminates with an error.- See Also:
- ReactiveX merge operator.
-
mergeDelayError
public final <T> Publisher<T> mergeDelayError(Publisher<? extends T> mergeWith)
Merges the passedPublisherwith thisCompletable.The resulting
Publisheremits all items emitted by the passedPublisherand terminates when both thisCompletableand the passedPublisherterminate. If either terminates with an error then the error will be propagated to the return value.ExecutorService e = ...; List<Future<Void>> futures = ...; futures.add(e.submit(() -> resultOfThisCompletable())); futures.add(e.submit(() -> resultOfMergeWithStream()); 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; }- Type Parameters:
T- The value type of the resultingPublisher.- Parameters:
mergeWith- thePublisherto merge in- Returns:
Publisheremits all items emitted by the passedPublisherand terminates when both thisCompletableand the passedPublisherterminate. If either terminates with an error then the error will be propagated to the return value.- See Also:
- ReactiveX merge operator.
-
mergeDelayError
public final Completable mergeDelayError(Completable other)
Merges thisCompletablewith theotherCompletable, and delays error notification until all involvedCompletables terminate.Use
merge(Completable)if any error should immediately terminate the returnedCompletable.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())); futures.add(e.submit(() -> resultOfCompletable(other)); 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; }- Parameters:
other-Completableto merge.- Returns:
Completablethat terminates afterthisCompletableandotherCompletable. If all involvedCompletables terminate successfully then the return value will terminate successfully. If anyCompletableterminates in an error, then the return value will also terminate in an error.
-
mergeDelayError
public final Completable mergeDelayError(Completable... other)
Merges thisCompletablewith theotherCompletables, and delays error notification until all involvedCompletables terminate.Use
merge(Completable...)if any error should immediately terminate the returnedCompletable.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; }- Parameters:
other-Completables to merge.- Returns:
Completablethat terminates afterthisCompletableand allotherCompletables. If all involvedCompletables terminate successfully then the return value will terminate successfully. If anyCompletableterminates in an error, then the return value will also terminate in an error.
-
mergeDelayError
public final Completable mergeDelayError(java.lang.Iterable<? extends Completable> other)
Merges thisCompletablewith theotherCompletables, and delays error notification until all involvedCompletables terminate.Use
merge(Iterable)if any error should immediately terminate the returnedCompletable.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; }- Parameters:
other-Completables to merge.- Returns:
Completablethat terminates afterthisCompletableand allotherCompletables. If all involvedCompletables terminate successfully then the return value will terminate successfully. If anyCompletableterminates in an error, then the return value will also terminate in an error.
-
retry
public final Completable retry(BiIntPredicate<java.lang.Throwable> shouldRetry)
Re-subscribes to thisCompletableif an error is emitted and the passedBiIntPredicatereturnstrue.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; } } }- Parameters:
shouldRetry-BiIntPredicatethat given the retry count and the most recentThrowableemitted from thisCompletabledetermines if the operation should be retried.- Returns:
- A
Completablethat completes with thisCompletableor re-subscribes if an error is emitted and if the passedBiPredicatereturnedtrue. - See Also:
- ReactiveX retry operator.
-
retryWhen
public final Completable retryWhen(BiIntFunction<java.lang.Throwable,? extends Completable> retryWhen)
Re-subscribes to thisCompletableif an error is emitted and theCompletablereturned by the suppliedBiIntFunctioncompletes successfully. If the returnedCompletableemits an error, the returnedCompletableterminates 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; } } }- Parameters:
retryWhen-BiIntFunctionthat given the retry count and the most recentThrowableemitted from thisCompletablereturns aCompletable. If thisCompletableemits an error, that error is emitted from the returnedCompletable, otherwise, originalCompletableis re-subscribed when thisCompletablecompletes.- Returns:
- A
Completablethat completes with thisCompletableor re-subscribes if an error is emitted andCompletablereturned byBiFunctioncompletes successfully. - See Also:
- ReactiveX retry operator.
-
repeat
public final Publisher<java.lang.Void> repeat(java.util.function.IntPredicate shouldRepeat)
Re-subscribes to thisCompletablewhen it completes and the passedIntPredicatereturnstrue.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));- Parameters:
shouldRepeat-IntPredicatethat given the repeat count determines if the operation should be repeated- Returns:
- A
Publisherthat emits the value returned by the passedSuppliereverytime thisCompletablecompletes. - See Also:
- ReactiveX repeat operator.
-
repeatWhen
public final Publisher<java.lang.Void> repeatWhen(java.util.function.IntFunction<? extends Completable> repeatWhen)
Re-subscribes to thisCompletablewhen it completes and theCompletablereturned by the suppliedIntFunctioncompletes successfully. If the returnedCompletableemits an error, the returnedCompletableemits 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; } }- Parameters:
repeatWhen-IntFunctionthat given the repeat count returns aCompletable. If thisCompletableemits an error repeat is terminated, otherwise, originalCompletableis re-subscribed when thisCompletablecompletes.- Returns:
- A
Completablethat completes after all re-subscriptions completes. - See Also:
- ReactiveX retry operator.
-
beforeOnSubscribe
public final Completable beforeOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
Invokes theonSubscribeConsumerargument beforeCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable.- Parameters:
onSubscribe- Invoked beforeCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
beforeOnComplete
public final Completable beforeOnComplete(java.lang.Runnable onComplete)
Invokes theonCompleteRunnableargument beforeCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable.From a sequential programming point of view this method is roughly equivalent to the following:
resultOfThisCompletable(); onComplete.run(); nextOperation();- Parameters:
onComplete- Invoked beforeCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
beforeOnError
public final Completable beforeOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes theonErrorConsumerargument beforeCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable.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); }- Parameters:
onError- Invoked beforeCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
beforeCancel
public final Completable beforeCancel(java.lang.Runnable onCancel)
Invokes theonCancelRunnableargument beforeCancellable.cancel()is called for Subscriptions of the returnedCompletable.- Parameters:
onCancel- Invoked beforeCancellable.cancel()is called for Subscriptions of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
beforeFinally
public final Completable beforeFinally(java.lang.Runnable doFinally)
Invokes thewhenFinallyRunnableargument before any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()
CompletableSource.Subscribers of the returnedCompletable.try { resultOfThisCompletable(); } finally { doFinally.run(); nextOperation(); // Maybe notifying of cancellation, or termination }- Parameters:
doFinally- Invoked before any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()
CompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable. - See Also:
- ReactiveX do operator.
-
beforeFinally
public final Completable beforeFinally(TerminalSignalConsumer doFinally)
Invokes the corresponding method onbeforeFinallyTerminalSignalConsumerargument before any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()CompletableSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()
CompletableSource.Subscribers of the returnedCompletable.From a sequential programming point of view this method is roughly equivalent to the following:
try { resultOfThisCompletable(); } catch(Throwable t) { doFinally.onError(t); nextOperation(); // Maybe notifying of cancellation, or termination return; } doFinally.onComplete(); nextOperation(); // Maybe notifying of cancellation, or termination- Parameters:
doFinally- For each subscribe of the returnedCompletable, at most one method of thisTerminalSignalConsumerwill be invoked.- Returns:
- The new
Completable. - See Also:
- ReactiveX do operator.
-
beforeSubscriber
public final Completable beforeSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
Creates a newCompletableSource.Subscriber(via thesubscriberSupplierargument) on each call to subscribe and invokes all theCompletableSource.Subscribermethods before theCompletableSource.Subscribers of the returnedCompletable.- Parameters:
subscriberSupplier- Creates a newCompletableSource.Subscriberon each call to subscribe and invokes all theCompletableSource.Subscribermethods before theCompletableSource.Subscribers of the returnedCompletable.CompletableSource.Subscribermethods MUST NOT throw.- Returns:
- The new
Completable.
-
afterOnSubscribe
public final Completable afterOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
Invokes theonSubscribeConsumerargument afterCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable.- Parameters:
onSubscribe- Invoked afterCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
whenOnSubscribe
public final Completable whenOnSubscribe(java.util.function.Consumer<Cancellable> onSubscribe)
Invokes theonSubscribeConsumerargument whenCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable.The order in which
onSubscribewill be invoked relative toCompletableSource.Subscriber.onSubscribe(Cancellable)is undefined. If you need strict ordering seebeforeOnSubscribe(Consumer)andafterOnSubscribe(Consumer).- Parameters:
onSubscribe- Invoked whenCompletableSource.Subscriber.onSubscribe(Cancellable)is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable. - See Also:
beforeOnSubscribe(Consumer),afterOnSubscribe(Consumer)
-
afterOnComplete
public final Completable afterOnComplete(java.lang.Runnable onComplete)
Invokes theonCompleteRunnableargument afterCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable.From a sequential programming point of view this method is roughly equivalent to the following:
resultOfThisCompletable(); nextOperation(); onComplete.run();- Parameters:
onComplete- Invoked afterCompletableSource.Subscriber.onComplete()is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
afterOnError
public final Completable afterOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes theonErrorConsumerargument afterCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable.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); }- Parameters:
onError- Invoked afterCompletableSource.Subscriber.onError(Throwable)is called forCompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
afterCancel
public final Completable afterCancel(java.lang.Runnable onCancel)
Invokes theonCancelRunnableargument afterCancellable.cancel()is called for Subscriptions of the returnedCompletable.- Parameters:
onCancel- Invoked afterCancellable.cancel()is called for Subscriptions of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable.
-
afterFinally
public final Completable afterFinally(java.lang.Runnable doFinally)
Invokes thewhenFinallyRunnableargument after any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()
CompletableSource.Subscribers of the returnedCompletable.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 doFinally.run(); }- Parameters:
doFinally- Invoked after any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()CompletableSource.Subscriber.onError(Throwable)Cancellable.cancel()
CompletableSource.Subscribers of the returnedCompletable. MUST NOT throw.- Returns:
- The new
Completable. - See Also:
- ReactiveX do operator.
-
afterFinally
public final Completable afterFinally(TerminalSignalConsumer doFinally)
Invokes the corresponding method onafterFinallyTerminalSignalConsumerargument after any of the following terminal methods are called:CompletableSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()CompletableSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()
CompletableSource.Subscribers of the returnedCompletable.From a sequential programming point of view this method is roughly equivalent to the following:
try { resultOfThisCompletable(); } catch(Throwable t) { nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onError(t); return; } nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onComplete();- Parameters:
doFinally- For each subscribe of the returnedCompletable, at most one method of thisTerminalSignalConsumerwill be invoked.- Returns:
- The new
Completable. - See Also:
- ReactiveX do operator.
-
afterSubscriber
public final Completable afterSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
Creates a newCompletableSource.Subscriber(via thesubscriberSupplierargument) on each call to subscribe and invokes all theCompletableSource.Subscribermethods after theCompletableSource.Subscribers of the returnedCompletable.- Parameters:
subscriberSupplier- Creates a newCompletableSource.Subscriberon each call to subscribe and invokes all theCompletableSource.Subscribermethods after theCompletableSource.Subscribers of the returnedCompletable.CompletableSource.Subscribermethods MUST NOT throw.- Returns:
- The new
Completable.
-
whenSubscriber
public final Completable whenSubscriber(java.util.function.Supplier<? extends CompletableSource.Subscriber> subscriberSupplier)
Creates a newCompletableSource.Subscriber(via thesubscriberSupplierargument) for each new subscribe and invokes methods on thatCompletableSource.Subscriberwhen the corresponding methods are called forCompletableSource.Subscribers of the returnedPublisher.- Parameters:
subscriberSupplier- Creates a newCompletableSource.Subscriberfor each new subscribe and invokes methods on thatCompletableSource.Subscriberwhen the corresponding methods are called forCompletableSource.Subscribers of the returnedPublisher.CompletableSource.Subscribermethods MUST NOT throw.- Returns:
- The new
Completable.
-
liftSync
public final Completable liftSync(CompletableOperator operator)
This method requires advanced knowledge of building operators. Before using this method please attempt to compose existing operator(s) to satisfy your use case.Returns a
Completablewhich will wrap theCompletableSource.Subscriberusing the providedoperatorargument before subscribing to thisCompletable.
TheCompletable<X> pub = ...; pub.map(..) // A .liftSync(original -> modified) .afterFinally(..) // Boriginal -> modified"operator" MUST be "synchronous" in that it does not interact with the originalCompletableSource.Subscriberfrom outside the modifiedCompletableSource.SubscriberorCancellablethreads. That is to say this operator will not impact theExecutorconstraints already in place between A and B above. If you need asynchronous behavior, or are unsure, seeliftAsync(CompletableOperator).- Parameters:
operator- The custom operator logic. The input is the "original"CompletableSource.Subscriberto thisCompletableand the return is the "modified"CompletableSource.Subscriberthat provides custom operator business logic.- Returns:
- a
Completablethat when subscribed, theoperatorargument will be used to wrap theCompletableSource.Subscriberbefore subscribing to thisCompletable. - See Also:
liftAsync(CompletableOperator)
-
liftAsync
public final Completable liftAsync(CompletableOperator operator)
This method requires advanced knowledge of building operators. Before using this method please attempt to compose existing operator(s) to satisfy your use case.Returns a
Completablewhich will wrap theCompletableSource.Subscriberusing the providedoperatorargument before subscribing to thisCompletable.
ThePublisher<X> pub = ...; pub.map(..) // A .liftAsync(original -> modified) .afterFinally(..) // Boriginal -> modified"operator" MAY be "asynchronous" in that it may interact with the originalCompletableSource.Subscriberfrom outside the modifiedCompletableSource.SubscriberorCancellablethreads. More specifically:- all of the
CompletableSource.Subscriberinvocations going "downstream" (i.e. from A to B above) MAY be offloaded via anExecutor - all of the
Cancellableinvocations going "upstream" (i.e. from B to A above) MAY be offloaded via anExecutor
- Parameters:
operator- The custom operator logic. The input is the "original"CompletableSource.Subscriberto thisCompletableand the return is the "modified"CompletableSource.Subscriberthat provides custom operator business logic.- Returns:
- a
Completablethat when subscribed, theoperatorargument will be used to wrap theCompletableSource.Subscriberbefore subscribing to thisCompletable. - See Also:
liftSync(CompletableOperator)
- all of the
-
publishOn
public final Completable publishOn(Executor executor)
Creates a newCompletablethat will use the passedExecutorto invoke allCompletableSource.Subscribermethods. This method does not override precedingExecutors, if any, specified forthisCompletable. Only subsequent operations, if any, added in this execution chain will use thisExecutor. If such an override is required,publishOnOverride(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Completablethat will use the passedExecutorto invoke all methods on theCompletableSource.Subscriber.
-
publishOnOverride
public final Completable publishOnOverride(Executor executor)
Creates a newCompletablethat will use the passedExecutorto invoke allCompletableSource.Subscribermethods. This method overrides precedingExecutors, if any, specified forthisCompletable. That is to say preceding and subsequent operations for this execution chain will use thisExecutor. If such an override is not required,publishOn(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Completablethat will use the passedExecutorto invoke all methods ofCompletableSource.Subscriber,CancellableandhandleSubscribe(CompletableSource.Subscriber)both for the returnedCompletableas well asthisCompletable.
-
subscribeOn
public final Completable subscribeOn(Executor executor)
Creates a newCompletablethat will use the passedExecutorto invoke the following methods:- All
Cancellablemethods. - The
handleSubscribe(CompletableSource.Subscriber)method.
Executors, if any, specified forthisCompletable. Only subsequent operations, if any, added in this execution chain will use thisExecutor. If such an override is required,subscribeOnOverride(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Completablethat will use the passedExecutorto invoke all methods ofCancellableandhandleSubscribe(CompletableSource.Subscriber).
- All
-
subscribeOnOverride
public final Completable subscribeOnOverride(Executor executor)
Creates a newCompletablethat will use the passedExecutorto invoke the following methods:- All
Cancellablemethods. - The
handleSubscribe(CompletableSource.Subscriber)method.
Executors, if any, specified forthisCompletable. That is to say preceding and subsequent operations for this execution chain will use thisExecutor. If such an override is not required,subscribeOn(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Completablethat will use the passedExecutorto invoke all methods ofCancellableandhandleSubscribe(CompletableSource.Subscriber)both for the returnedCompletableas well asthisCompletable.
- All
-
publishAndSubscribeOn
public final Completable publishAndSubscribeOn(Executor executor)
Creates a newCompletablethat will use the passedExecutorto invoke the following methods:- All
CompletableSource.Subscribermethods. - All
Cancellablemethods. - The
handleSubscribe(CompletableSource.Subscriber)method.
Executors, if any, specified forthisCompletable. Only subsequent operations, if any, added in this execution chain will use thisExecutor. If such an override is required,publishAndSubscribeOnOverride(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Completablethat will use the passedExecutorto invoke all methodsCompletableSource.Subscriber,CancellableandhandleSubscribe(CompletableSource.Subscriber).
- All
-
publishAndSubscribeOnOverride
public final Completable publishAndSubscribeOnOverride(Executor executor)
Creates a newCompletablethat will use the passedExecutorto invoke the following methods:- All
CompletableSource.Subscribermethods. - All
Cancellablemethods. - The
handleSubscribe(CompletableSource.Subscriber)method.
Executors, if any, specified forthisCompletable. That is to say preceding and subsequent operations for this execution chain will use thisExecutor. If such an override is not required,publishAndSubscribeOn(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Completablethat will use the passedExecutorto invoke all methods ofCompletableSource.Subscriber,CancellableandhandleSubscribe(CompletableSource.Subscriber)both for the returnedCompletableas well asthisCompletable.
- All
-
subscribeShareContext
public final Completable subscribeShareContext()
Signifies that when the returnedCompletableis subscribed to, theAsyncContextwill be shared instead of making acopy.This operator only impacts behavior if the returned
Completableis subscribed directly after this operator, that means this must be the "last operator" in the chain for this to have an impact.- Returns:
- A
Completablethat will share theAsyncContextinstead of making acopywhen subscribed to.
-
ambWith
public final Completable ambWith(Completable other)
Creates a newCompletablethat terminates with the result (either success or error) of either thisCompletableor the passedotherCompletable, whichever terminates first.From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<T> ft: futures) { // Provided Futures (analogous to the Completables here) // This is an approximation, this operator will pick the first result from either of the futures. return ft.get(); }- Parameters:
other-Completablewith which the result of thisCompletableis to be ambiguated.- Returns:
- A new
Completablethat terminates with the result (either success or error) of either thisCompletableor the passedotherCompletable, whichever terminates first. - See Also:
- ReactiveX amb operator.
-
toPublisher
public final <T> Publisher<T> toPublisher()
Converts thisCompletableto aPublisher.No
PublisherSource.Subscriber.onNext(Object)signals will be delivered to the returnedPublisher. Only terminal signals will be delivered. If you need more control you should consider usingconcat(Publisher).- Type Parameters:
T- The value type of the resultingPublisher.- Returns:
- A
Publisherthat mirrors the terminal signal from thisCompletable.
-
toSingle
public final Single<java.lang.Void> toSingle()
Converts thisCompletableto aSingle.- Returns:
- A
Singlethat mirrors the terminal signal from thisCompletable.
-
toCompletionStage
public final java.util.concurrent.CompletionStage<java.lang.Void> toCompletionStage()
Converts thisCompletableto aCompletionStage.- Returns:
- A
CompletionStagethat mirrors the terminal signal from thisCompletable.
-
toFuture
public final java.util.concurrent.Future<java.lang.Void> toFuture()
Converts thisCompletableto aFuture.- Returns:
- A
Futurethat mirrors the terminal signal from thisCompletable.
-
subscribeInternal
protected final void subscribeInternal(CompletableSource.Subscriber subscriber)
A internal subscribe method similar toCompletableSource.subscribe(Subscriber)which can be used by different implementations to subscribe.- Parameters:
subscriber-CompletableSource.Subscriberto subscribe for the result.
-
subscribe
public final Cancellable subscribe()
Subscribe to thisCompletableand log anyCompletableSource.Subscriber.onError(Throwable).- Returns:
Cancellableused to invokeCancellable.cancel()on the parameter ofCompletableSource.Subscriber.onSubscribe(Cancellable)for thisCompletable.
-
subscribe
public final Cancellable subscribe(java.lang.Runnable onComplete)
Subscribe to thisCompletableand log anyCompletableSource.Subscriber.onError(Throwable). PassedRunnableis invoked when thisCompletableterminates successfully.- Parameters:
onComplete-Runnableto invoke when thisCompletableterminates successfully.- Returns:
Cancellableused to invokeCancellable.cancel()on the parameter ofCompletableSource.Subscriber.onSubscribe(Cancellable)for thisCompletable.
-
handleSubscribe
protected abstract void handleSubscribe(CompletableSource.Subscriber subscriber)
Handles a subscriber to thisCompletable.This method is invoked internally by
Completablefor every call to thesubscribeInternal(CompletableSource.Subscriber)method.- Parameters:
subscriber- the subscriber.
-
completed
public static Completable completed()
Creates a realized completedCompletable.- Returns:
- A new
Completable.
-
fromRunnable
public static Completable fromRunnable(java.lang.Runnable runnable)
Creates aCompletablewhich when subscribed will invokeRunnable.run()on the passedRunnableand emit the value returned by that invocation from the returnedCompletable. Any error emitted by theRunnablewill terminate the returnedCompletablewith the same error.Blocking inside
Runnable.run()will in turn block the subscribe call to the returnedCompletable. If this behavior is undesirable then the returnedCompletableshould be offloaded using one of the operators that offloads the subscribe call (eg:subscribeOn(Executor),publishAndSubscribeOn(Executor)).- Parameters:
runnable-Runnablewhich is invoked before completion.- Returns:
- A new
Completable.
-
failed
public static Completable failed(java.lang.Throwable cause)
Creates a realized failedCompletable.- Parameters:
cause- error that the returnedCompletablecompletes with.- Returns:
- A new
Completable.
-
never
public static Completable never()
Creates aCompletablethat never terminates.- Returns:
- A new
Completable.
-
defer
public static Completable defer(java.util.function.Supplier<? extends Completable> completableSupplier)
Defer creation of aCompletabletill it is subscribed to.- Parameters:
completableSupplier-Supplierto create a newCompletablefor every call tosubscribeInternal(CompletableSource.Subscriber)to the returnedCompletable.- Returns:
- A new
Completablethat creates a newCompletableusingcompletableFactoryfor every call tosubscribeInternal(CompletableSource.Subscriber)and forwards the termination signal from the newly createdCompletableto itsCompletableSource.Subscriber.
-
fromFuture
public static Completable fromFuture(java.util.concurrent.Future<?> future)
Convert from aFutureto aCompletableviaFuture.get().Note that because
Futureonly presents blocking APIs to extract the result, so the process of getting the results will block. The caller ofsubscribeInternal(CompletableSource.Subscriber)is responsible for offloading if necessary, and also offloading ifCancellable.cancel()will be called if this operation may block.To apply a timeout see
timeout(long, TimeUnit)and related methods.- Parameters:
future- TheFutureto convert.- Returns:
- A
Completablethat derives results fromFuture. - See Also:
timeout(long, TimeUnit)
-
fromStage
public static Completable fromStage(java.util.concurrent.CompletionStage<?> stage)
Convert from aCompletionStageto aCompletable.A best effort is made to propagate
Cancellable.cancel()to theCompletionStage. Cancellation forCompletionStageimplementations 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 anExecutoris appropriate.- Parameters:
stage- TheCompletionStageto convert.- Returns:
- A
Completablethat derives results fromCompletionStage.
-
mergeAll
public static Completable mergeAll(java.lang.Iterable<? extends Completable> completables)
Returns aCompletablethat terminates when all the passedCompletableterminate.This will actively subscribe to a default number of
Completables concurrently, in order to alter the defaults,mergeAll(Iterable, int).If any of the
Completables terminate with an error, returnedCompletablewill immediately terminate with that error. In such a case, any in-progressCompletables will be cancelled. In order to delay error termination usemergeAllDelayError(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(); }- Parameters:
completables-IterableofCompletables, results of which are to be collected.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAll
public static Completable mergeAll(Completable... completables)
Returns aCompletablethat terminates when all the passedCompletableterminate.This will actively subscribe to a default number of
Completables concurrently, in order to alter the defaults,mergeAll(int, Completable...)should be used.If any of the
Completables terminate with an error, returnedCompletablewill immediately terminate with that error. In such a case, any in-progressCompletables will be cancelled. In order to delay error termination usemergeAllDelayError(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(); }- Parameters:
completables-Completables, results of which are to be collected.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAll
public static Completable mergeAll(java.lang.Iterable<? extends Completable> completables, int maxConcurrency)
Returns aCompletablethat terminates when all the passedCompletableterminate.If any of the
Completables terminate with an error, returnedCompletablewill immediately terminate with that error. In such a case, any in-progressCompletables will be cancelled. In order to delay error termination usemergeAllDelayError(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(); }- Parameters:
completables-IterableofCompletables, results of which are to be collected.maxConcurrency- Maximum number ofCompletables that will be active at any point in time.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAll
public static Completable mergeAll(int maxConcurrency, Completable... completables)
Returns aCompletablethat terminates when all the passedCompletableterminate.If any of the
Completables terminate with an error, returnedCompletablewill immediately terminate with that error. In such a case, any in-progressCompletables will be cancelled. In order to delay error termination usemergeAllDelayError(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(); }- Parameters:
maxConcurrency- Maximum number ofCompletables that will be active at any point in time.completables-Completables, results of which are to be collected.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAllDelayError
public static Completable mergeAllDelayError(java.lang.Iterable<? extends Completable> completables)
Returns aCompletablethat terminates when all the passedCompletableterminate.This will actively subscribe to a default number of
Completables concurrently, in order to alter the defaults,mergeAllDelayError(Iterable, int)should be used.If any of the
Completables terminate with an error, returnedCompletablewill wait for termination till all the otherCompletables have been subscribed and terminated. If it is expected for the returnedCompletableto terminate on the first failingCompletable,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);- Parameters:
completables-IterableofCompletables, results of which are to be collected.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAllDelayError
public static Completable mergeAllDelayError(Completable... completables)
Returns aCompletablethat terminates when all the passedCompletableterminate.This will actively subscribe to a limited number of
Singles concurrently, in order to alter the defaults,mergeAll(int, Completable...)should be used.If any of the
Singles terminate with an error, returnedSinglewill wait for termination till all the otherSingles have been subscribed and terminated. If it is expected for the returnedSingleto terminate on the first failingSingle,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);- Parameters:
completables-Completables, results of which are to be collected.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAllDelayError
public static Completable mergeAllDelayError(java.lang.Iterable<? extends Completable> completables, int maxConcurrency)
Returns aCompletablethat terminates when all the passedCompletableterminate.If any of the
Singles terminate with an error, returnedSinglewill wait for termination till all the otherSingles have been subscribed and terminated. If it is expected for the returnedSingleto terminate on the first failingSingle,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);- Parameters:
completables-IterableofCompletables, results of which are to be collected.maxConcurrency- Maximum number ofCompletables that will be active at any point in time.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
mergeAllDelayError
public static Completable mergeAllDelayError(int maxConcurrency, Completable... completables)
Returns aCompletablethat terminates when all the passedCompletableterminate.If any of the
Singles terminate with an error, returnedSinglewill wait for termination till all the otherSingles have been subscribed and terminated. If it is expected for the returnedSingleto terminate on the first failingSingle,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);- Parameters:
maxConcurrency- Maximum number ofCompletables that will be active at any point in time.completables-Completables, results of which are to be collected.- Returns:
- A new
Completablethat terminates successfully if all the providedCompletables have terminated successfully or any one of them has terminated with a failure.
-
amb
public static Completable amb(Completable... completables)
Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<T> ft: futures) { // Provided Futures (analogous to the Completables here) // This is an approximation, this operator will pick the first result from any of the futures. return ft.get(); }- Parameters:
completables-Completables the result of which are to be ambiguated.- Returns:
- A new
Completablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first. - See Also:
- ReactiveX amb operator.
-
amb
public static Completable amb(java.lang.Iterable<Completable> completables)
Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<T> ft: futures) { // Provided Futures (analogous to the Completables here) // This is an approximation, this operator will pick the first result from any of the futures. return ft.get(); }- Parameters:
completables-Completables the result of which are to be ambiguated.- Returns:
- A new
Completablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first. that result. - See Also:
- ReactiveX amb operator.
-
anyOf
public static Completable anyOf(Completable... completables)
Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<T> ft: futures) { // Provided Futures (analogous to the Completables here) // This is an approximation, this operator will pick the first result from any of the futures. return ft.get(); }- Parameters:
completables-Completables the result of which are to be ambiguated.- Returns:
- A new
Completablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first. - See Also:
- ReactiveX amb operator.
-
anyOf
public static Completable anyOf(java.lang.Iterable<Completable> completables)
Creates a newCompletablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first.From a sequential programming point of view this method is roughly equivalent to the following:
for (Future<T> ft: futures) { // Provided Futures (analogous to the Completables here) // This is an approximation, this operator will pick the first result from any of the futures. return ft.get(); }- Parameters:
completables-Completables the result of which are to be ambiguated.- Returns:
- A new
Completablethat terminates with the result (either success or error) of whichever amongst the passedcompletablesthat terminates first. that result. - See Also:
- ReactiveX amb operator.
-
-