Class CompletableSubject
- All Implemented Interfaces:
CompletableObserver, CompletableSource
This subject does not have a public constructor by design; a new non-terminated instance of this
CompletableSubject can be created via the create() method.
Since the CompletableSubject is conceptionally derived from the Processor type in the Reactive Streams specification,
nulls are not allowed (Rule 2.13)
as parameters to onError(Throwable).
Even though CompletableSubject implements the CompletableObserver interface, calling
onSubscribe is not required (Rule 2.12)
if the subject is used as a standalone source. However, calling onSubscribe
after the CompletableSubject reached its terminal state will result in the
given Disposable being disposed immediately.
All methods are thread safe. Calling onComplete() multiple
times has no effect. Calling onError(Throwable) multiple times relays the Throwable to
the RxJavaPlugins.onError(Throwable) global error handler.
This CompletableSubject supports the standard state-peeking methods hasComplete(),
hasThrowable(), getThrowable() and hasObservers().
- Scheduler:
CompletableSubjectdoes not operate by default on a particularSchedulerand theCompletableObservers get notified on the thread where the terminatingonErrororonCompletemethods were invoked.- Error handling:
- When the
onError(Throwable)is called, theCompletableSubjectenters into a terminal state and emits the sameThrowableinstance to the last set ofCompletableObservers. During this emission, if one or moreCompletableObservers dispose their respectiveDisposables, theThrowableis delivered to the global error handler viaRxJavaPlugins.onError(Throwable)(multiple times if multipleCompletableObservers cancel at once). If there were noCompletableObservers subscribed to thisCompletableSubjectwhen theonError()was called, the global error handler is not invoked.
Example usage:
CompletableSubject subject = CompletableSubject.create();
TestObserver<Void> to1 = subject.test();
// a fresh CompletableSubject is empty
to1.assertEmpty();
subject.onComplete();
// a CompletableSubject is always void of items
to1.assertResult();
TestObserver<Void> to2 = subject.test()
// late CompletableObservers receive the terminal event
to2.assertResult();
History: 2.0.5 - experimental
- Since:
- 2.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull CompletableSubjectcreate()Creates a fresh CompletableSubject.Returns the terminal error if this CompletableSubject has been terminated with an error, null otherwise.booleanReturns true if this CompletableSubject has been completed.booleanReturns true if this CompletableSubject has observers.booleanReturns true if this CompletableSubject has been terminated with an error.voidCalled once the deferred computation completes normally.voidCalled once if the deferred computation 'throws' an exception.voidCalled once by theCompletableto set aDisposableon this instance which then can be used to cancel the subscription at any time.protected voidsubscribeActual(CompletableObserver observer) Implement this method to handle the incomingCompletableObservers and perform the business logic in your operator.Methods inherited from class Completable
amb, ambArray, ambWith, andThen, andThen, andThen, andThen, andThen, blockingAwait, blockingAwait, blockingSubscribe, blockingSubscribe, blockingSubscribe, blockingSubscribe, cache, complete, compose, concat, concat, concat, concatArray, concatArrayDelayError, concatDelayError, concatDelayError, concatDelayError, concatWith, create, defer, delay, delay, delay, delaySubscription, delaySubscription, doAfterTerminate, doFinally, doOnComplete, doOnDispose, doOnError, doOnEvent, doOnLifecycle, doOnSubscribe, doOnTerminate, error, error, fromAction, fromCallable, fromCompletionStage, fromFuture, fromMaybe, fromObservable, fromPublisher, fromRunnable, fromSingle, fromSupplier, hide, lift, materialize, merge, merge, merge, mergeArray, mergeArrayDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeWith, never, observeOn, onErrorComplete, onErrorComplete, onErrorResumeNext, onErrorResumeWith, onErrorReturn, onErrorReturnItem, onTerminateDetach, repeat, repeat, repeatUntil, repeatWhen, retry, retry, retry, retry, retry, retryUntil, retryWhen, safeSubscribe, sequenceEqual, startWith, startWith, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscribeWith, switchOnNext, switchOnNextDelayError, takeUntil, test, test, timeout, timeout, timeout, timeout, timer, timer, to, toCompletionStage, toFlowable, toFuture, toMaybe, toObservable, toSingle, toSingleDefault, unsafeCreate, unsubscribeOn, using, using, wrapModifier and TypeMethodDescriptionstatic @NonNull Completableamb(@NonNull Iterable<@NonNull ? extends CompletableSource> sources) Returns aCompletablewhich terminates as soon as one of the sourceCompletables in theIterablesequence terminates (normally or with an error) and disposes all otherCompletables.static @NonNull CompletableambArray(@NonNull CompletableSource... sources) Returns aCompletablewhich terminates as soon as one of the sourceCompletables terminates (normally or with an error) and disposes all otherCompletables.final @NonNull CompletableambWith(@NonNull CompletableSource other) Returns aCompletablethat emits the a terminated event of either thisCompletableor the otherCompletableSource, whichever fires first.final @NonNull CompletableandThen(@NonNull CompletableSource next) andThen(@NonNull MaybeSource<@NonNull T> next) Returns aMaybewhich will subscribe to thisCompletableand once that is completed then will subscribe to thenextMaybeSource.final <@NonNull T>
@NonNull Observable<T> andThen(@NonNull ObservableSource<@NonNull T> next) Returns anObservablewhich will subscribe to thisCompletableand once that is completed then will subscribe to thenextObservableSource.andThen(@NonNull SingleSource<@NonNull T> next) Returns aSinglewhich will subscribe to thisCompletableand once that is completed then will subscribe to thenextSingleSource.andThen(@NonNull Flow.Publisher<@NonNull T> next) Returns aFlowablewhich will subscribe to thisCompletableand once that is completed then will subscribe to thenextFlow.Publisher.final voidSubscribes to and awaits the termination of thisCompletableinstance in a blocking manner and rethrows any exception emitted.final booleanblockingAwait(long timeout, @NonNull TimeUnit unit) Subscribes to and awaits the termination of thisCompletableinstance in a blocking manner with a specific timeout and rethrows any exception emitted within the timeout window.final voidSubscribes to the currentCompletableand blocks the current thread until it terminates.final voidblockingSubscribe(@NonNull CompletableObserver observer) Subscribes to the currentCompletableand calls the appropriateCompletableObservermethod on the current thread.final voidblockingSubscribe(@NonNull Action onComplete) Subscribes to the currentCompletableand calls givenonCompletecallback on the current thread when it completes normally.final voidSubscribes to the currentCompletableand calls the appropriate callback on the current thread when it terminates.final @NonNull Completablecache()Subscribes to thisCompletableonly once, when the firstCompletableObserversubscribes to the resultCompletable, caches its terminal event and relays/replays it to observers.static @NonNull Completablecomplete()Returns aCompletableinstance that completes immediately when subscribed to.final @NonNull Completablecompose(@NonNull CompletableTransformer transformer) Calls the given transformer function with this instance and returns the function's resultingCompletableSourcewrapped withCompletable.wrap(CompletableSource).static @NonNull Completableconcat(@NonNull Iterable<@NonNull ? extends CompletableSource> sources) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull Completableconcat(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull Completableconcat(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources, int prefetch) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull CompletableconcatArray(@NonNull CompletableSource... sources) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull CompletableconcatArrayDelayError(@NonNull CompletableSource... sources) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull CompletableconcatDelayError(@NonNull Iterable<@NonNull ? extends CompletableSource> sources) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull CompletableconcatDelayError(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources) Returns aCompletablewhich completes only when all sources complete, one after another.static @NonNull CompletableconcatDelayError(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources, int prefetch) Returns aCompletablewhich completes only when all sources complete, one after another.final @NonNull CompletableconcatWith(@NonNull CompletableSource other) Concatenates thisCompletablewith anotherCompletableSource.static @NonNull Completablecreate(@NonNull CompletableOnSubscribe source) Provides an API (via a coldCompletable) that bridges the reactive world with the callback-style world.static @NonNull Completabledefer(@NonNull Supplier<? extends @NonNull CompletableSource> supplier) Defers the subscription to aCompletableinstance returned by a supplier.final @NonNull CompletableReturns aCompletablewhich delays the emission of the completion event by the given time.final @NonNull CompletableReturns aCompletablewhich delays the emission of the completion event by the given time while running on the specifiedScheduler.final @NonNull CompletableReturns aCompletablewhich delays the emission of the completion event, and optionally the error as well, by the given time while running on the specifiedScheduler.final @NonNull CompletabledelaySubscription(long time, @NonNull TimeUnit unit) Returns aCompletablethat delays the subscription to the upstream by a given amount of time.final @NonNull CompletabledelaySubscription(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) Returns aCompletablethat delays the subscription to the upstream by a given amount of time, both waiting and subscribing on a givenScheduler.final @NonNull CompletabledoAfterTerminate(@NonNull Action onAfterTerminate) Returns aCompletableinstance that calls the givenonAfterTerminateActionafter thisCompletablecompletes normally or with an exception.final @NonNull CompletableCalls the specifiedActionafter thisCompletablesignalsonErrororonCompleteor gets disposed by the downstream.final @NonNull CompletabledoOnComplete(@NonNull Action onComplete) final @NonNull CompletabledoOnDispose(@NonNull Action onDispose) Calls the sharedActionif aCompletableObserversubscribed to the currentCompletabledisposes the commonDisposableit received viaonSubscribe.final @NonNull Completablefinal @NonNull Completablefinal @NonNull CompletabledoOnLifecycle(@NonNull Consumer<? super Disposable> onSubscribe, @NonNull Action onDispose) Calls the appropriateonXXXmethod (shared between allCompletableObservers) for the lifecycle events of the sequence (subscription, disposal).final @NonNull CompletabledoOnSubscribe(@NonNull Consumer<? super Disposable> onSubscribe) Returns aCompletableinstance that calls the givenonSubscribecallback with the disposable that the downstreamCompletableObservers receive upon subscription.final @NonNull CompletabledoOnTerminate(@NonNull Action onTerminate) Returns aCompletableinstance that calls the givenonTerminateActionjust before thisCompletablecompletes normally or with an exception.static @NonNull CompletableCreates aCompletablewhich calls the given error supplier for each subscriber and emits its returnedThrowable.static @NonNull CompletableCreates aCompletableinstance that emits the givenThrowableexception to subscribers.static @NonNull CompletablefromAction(@NonNull Action action) Returns aCompletableinstance that runs the givenActionfor eachCompletableObserverand emits either an exception or simply completes.static @NonNull CompletablefromCallable(@NonNull Callable<?> callable) Returns aCompletablewhich when subscribed, executes theCallablefunction, ignores its normal result and emitsonErrororonCompleteonly.static @NonNull CompletablefromCompletionStage(@NonNull CompletionStage<?> stage) Signals completion (or error) when theCompletionStageterminates.static @NonNull CompletablefromFuture(@NonNull Future<?> future) Returns aCompletableinstance that reacts to the termination of the givenFuturein a blocking fashion.static <@NonNull T>
@NonNull CompletablefromMaybe(@NonNull MaybeSource<@NonNull T> maybe) Returns aCompletableinstance that when subscribed to, subscribes to theMaybeSourceinstance and emits anonCompleteevent if the maybe emitsonSuccess/onCompleteor forwards anyonErrorevents.static <@NonNull T>
@NonNull CompletablefromObservable(@NonNull ObservableSource<@NonNull T> observable) Returns aCompletableinstance that subscribes to the givenObservableSource, ignores all values and emits only the terminal event.static <@NonNull T>
@NonNull CompletablefromPublisher(@NonNull Flow.Publisher<@NonNull T> publisher) Returns aCompletableinstance that subscribes to the givenFlow.Publisher, ignores all values and emits only the terminal event.static @NonNull CompletablefromRunnable(@NonNull Runnable run) Returns aCompletableinstance that runs the givenRunnablefor eachCompletableObserverand emits either its unchecked exception or simply completes.static <@NonNull T>
@NonNull CompletablefromSingle(@NonNull SingleSource<@NonNull T> single) Returns aCompletableinstance that when subscribed to, subscribes to theSingleSourceinstance and emits a completion event if the single emitsonSuccessor forwards anyonErrorevents.static @NonNull CompletablefromSupplier(@NonNull Supplier<?> supplier) Returns aCompletablewhich when subscribed, executes theSupplierfunction, ignores its normal result and emitsonErrororonCompleteonly.final @NonNull Completablehide()Hides the identity of thisCompletableand itsDisposable.final @NonNull Completablelift(@NonNull CompletableOperator onLift) This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns aCompletablewhich, when subscribed to, invokes theapply(CompletableObserver)method of the providedCompletableOperatorfor each individual downstreamCompletableand allows the insertion of a custom operator by accessing the downstream'sCompletableObserverduring this subscription phase and providing a newCompletableObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.final <@NonNull T>
@NonNull Single<Notification<T>> Maps the signal types of thisCompletableinto aNotificationof the same kind and emits it as a single success value to downstream.static @NonNull Completablemerge(@NonNull Iterable<@NonNull ? extends CompletableSource> sources) Returns aCompletableinstance that subscribes to all sources at once and completes only when all sourceCompletableSources complete or one of them emits an error.static @NonNull Completablemerge(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources) Returns aCompletableinstance that subscribes to all sources at once and completes only when all sourceCompletableSources complete or one of them emits an error.static @NonNull Completablemerge(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources, int maxConcurrency) Returns aCompletableinstance that keeps subscriptions to a limited number of sources at once and completes only when all sourceCompletableSources complete or one of them emits an error.static @NonNull CompletablemergeArray(@NonNull CompletableSource... sources) Returns aCompletableinstance that subscribes to all sources at once and completes only when all sourceCompletableSources complete or one of them emits an error.static @NonNull CompletablemergeArrayDelayError(@NonNull CompletableSource... sources) Returns aCompletablethat subscribes to allCompletableSources in the source array and delays any error emitted by any of the innerCompletableSources until all of them terminate in a way or another.static @NonNull CompletablemergeDelayError(@NonNull Iterable<@NonNull ? extends CompletableSource> sources) Returns aCompletablethat subscribes to allCompletableSources in the source sequence and delays any error emitted by any of the innerCompletableSources until all of them terminate in a way or another.static @NonNull CompletablemergeDelayError(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources) Returns aCompletablethat subscribes to allCompletableSources in the source sequence and delays any error emitted by either the sourcesFlow.Publisheror any of the innerCompletableSources until all of them terminate in a way or another.static @NonNull CompletablemergeDelayError(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources, int maxConcurrency) Returns aCompletablethat subscribes to a limited number of innerCompletableSources at once in the source sequence and delays any error emitted by either the sourcesFlow.Publisheror any of the innerCompletableSources until all of them terminate in a way or another.final @NonNull CompletablemergeWith(@NonNull CompletableSource other) Returns aCompletablewhich subscribes to this and the otherCompletableSourceand completes when both of them complete or one emits an error.static @NonNull Completablenever()Returns aCompletablethat never callsonErrororonComplete.final @NonNull CompletableReturns aCompletablewhich emits the terminal events from the thread of the specifiedScheduler.final @NonNull CompletableReturns aCompletableinstance that if thisCompletableemits an error, it will emit anonCompleteand swallow the upstreamThrowable.final @NonNull CompletableonErrorComplete(@NonNull Predicate<? super Throwable> predicate) final @NonNull CompletableonErrorResumeNext(@NonNull Function<? super Throwable, ? extends CompletableSource> fallbackSupplier) Returns aCompletableinstance that when encounters an error from thisCompletable, calls the specifiedmapperFunctionthat returns aCompletableSourceinstance for it and resumes the execution with it.final @NonNull CompletableonErrorResumeWith(@NonNull CompletableSource fallback) Resumes the flow with the givenCompletableSourcewhen the currentCompletablefails instead of signaling the error viaonError.onErrorReturn(@NonNull Function<? super Throwable, ? extends @NonNull T> itemSupplier) Ends the flow with a success item returned by a function for theThrowableerror signaled by the currentCompletableinstead of signaling the error viaonError.onErrorReturnItem(@NonNull T item) Ends the flow with the given success item when the currentCompletablefails instead of signaling the error viaonError.final @NonNull CompletableNulls out references to the upstream producer and downstreamCompletableObserverif the sequence is terminated or downstream callsdispose().final @NonNull Completablerepeat()Returns aCompletablethat repeatedly subscribes to thisCompletableuntil disposed.final @NonNull Completablerepeat(long times) Returns aCompletablethat subscribes repeatedly at most the given number of times to thisCompletable.final @NonNull CompletableReturns aCompletablethat repeatedly subscribes to thisCompletableso long as the given stopBooleanSupplierreturnsfalse.final @NonNull CompletablerepeatWhen(@NonNull Function<? super Flowable<Object>, @NonNull ? extends Flow.Publisher<@NonNull ?>> handler) Returns aCompletableinstance that repeats when theFlow.Publisherreturned by the handlerFunctionemits an item or completes when thisPublisheremits anonCompleteevent.final @NonNull Completableretry()Returns aCompletablethat retries thisCompletableas long as it emits anonErrorevent.final @NonNull Completableretry(long times) Returns aCompletablethat when thisCompletableemits an error, retries at most the given number of times before giving up and emitting the last error.final @NonNull CompletableReturns aCompletablethat when thisCompletableemits an error, retries at most times or until the predicate returnsfalse, whichever happens first and emitting the last error.final @NonNull Completableretry(@NonNull BiPredicate<? super Integer, ? super Throwable> predicate) Returns aCompletablethat retries thisCompletablein case of an error as long as thepredicatereturnstrue.final @NonNull CompletableReturns aCompletablethat when thisCompletableemits an error, calls the given predicate with the latestThrowableto decide whether to resubscribe to the upstream or not.final @NonNull CompletableRetries until the given stop function returnstrue.final @NonNull CompletableretryWhen(@NonNull Function<? super Flowable<Throwable>, @NonNull ? extends Flow.Publisher<@NonNull ?>> handler) Returns aCompletablewhich given aFlow.Publisherand when thisCompletableemits an error, delivers that error through aFlowableand thePublishershould signal a value indicating a retry in response or a terminal event indicating a termination.final voidsafeSubscribe(@NonNull CompletableObserver observer) Wraps the givenCompletableObserver, catches anyRuntimeExceptions thrown by itsCompletableObserver.onSubscribe(Disposable),CompletableObserver.onError(Throwable)orCompletableObserver.onComplete()methods and routes those to the global error handler viaRxJavaPlugins.onError(Throwable).sequenceEqual(@NonNull CompletableSource source1, @NonNull CompletableSource source2) final @NonNull CompletablestartWith(@NonNull CompletableSource other) Returns aCompletablewhich first runs the otherCompletableSourcethen the currentCompletableif the other completed normally.startWith(@NonNull MaybeSource<@NonNull T> other) Returns aFlowablewhich first runs the otherMaybeSourcethen the currentCompletableif the other succeeded or completed normally.final <@NonNull T>
@NonNull Observable<T> startWith(@NonNull ObservableSource<@NonNull T> other) Returns anObservablewhich first delivers the events of the otherObservableSourcethen runs the currentCompletable.startWith(@NonNull SingleSource<@NonNull T> other) Returns aFlowablewhich first runs the otherSingleSourcethen the currentCompletableif the other succeeded normally.startWith(@NonNull Flow.Publisher<@NonNull T> other) Returns aFlowablewhich first delivers the events of the otherFlow.Publisherthen runs the currentCompletable.final @NonNull DisposableSubscribes to thisCompletableand returns aDisposablewhich can be used to dispose the subscription.final voidsubscribe(@NonNull CompletableObserver observer) Subscribes the givenCompletableObserverto thisCompletableSourceinstance.final @NonNull Disposablefinal @NonNull DisposableSubscribes to thisCompletableand calls back either theonErrororonCompletefunctions.final @NonNull Disposablesubscribe(@NonNull Action onComplete, @NonNull Consumer<? super Throwable> onError, @NonNull DisposableContainer container) Wraps the given onXXX callbacks into aDisposableCompletableObserver, adds it to the givenDisposableContainerand ensures, that if the upstream terminates or this particularDisposableis disposed, theCompletableObserveris removed from the given composite.final @NonNull CompletablesubscribeOn(@NonNull Scheduler scheduler) Returns aCompletablewhich subscribes the downstream subscriber on the specified scheduler, making sure the subscription side-effects happen on that specific thread of theScheduler.final <@NonNull E extends CompletableObserver>
EsubscribeWith(@NonNull E observer) Subscribes a givenCompletableObserver(subclass) to thisCompletableand returns the givenCompletableObserveras is.static @NonNull CompletableswitchOnNext(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources) Switches betweenCompletableSources emitted by the sourceFlow.Publisherwhenever a newCompletableSourceis emitted, disposing the previously runningCompletableSource, exposing the setup as aCompletablesequence.static @NonNull CompletableswitchOnNextDelayError(@NonNull Flow.Publisher<@NonNull ? extends CompletableSource> sources) Switches betweenCompletableSources emitted by the sourceFlow.Publisherwhenever a newCompletableSourceis emitted, disposing the previously runningCompletableSource, exposing the setup as aCompletablesequence and delaying all errors from all of them until all terminate.final @NonNull CompletabletakeUntil(@NonNull CompletableSource other) Terminates the downstream if this or the otherCompletableterminates (wins the termination race) while disposing the connection to the losing source.final @NonNull TestObserver<Void> test()Creates aTestObserverand subscribes it to thisCompletable.final @NonNull TestObserver<Void> test(boolean dispose) Creates aTestObserveroptionally in cancelled state, then subscribes it to thisCompletable.final @NonNull CompletableReturns aCompletable that runs thisCompletableand emits aTimeoutExceptionin case thisCompletabledoesn't complete within the given time.final @NonNull Completabletimeout(long timeout, @NonNull TimeUnit unit, @NonNull CompletableSource fallback) Returns aCompletablethat runs thisCompletableand switches to the otherCompletableSourcein case thisCompletabledoesn't complete within the given time.final @NonNull CompletableReturns aCompletablethat runs thisCompletableand emits aTimeoutExceptionin case thisCompletabledoesn't complete within the given time while "waiting" on the specifiedScheduler.final @NonNull Completabletimeout(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, @NonNull CompletableSource fallback) Returns aCompletablethat runs thisCompletableand switches to the otherCompletableSourcein case thisCompletabledoesn't complete within the given time while "waiting" on the specifiedScheduler.static @NonNull CompletableReturns aCompletableinstance that fires itsonCompleteevent after the given delay elapsed.static @NonNull CompletableReturns aCompletableinstance that fires itsonCompleteevent after the given delay elapsed by using the suppliedScheduler.final <R> Rto(@NonNull CompletableConverter<? extends R> converter) Calls the specifiedCompletableConverterfunction during assembly time and returns its resulting value.final <@Nullable T>
@NonNull CompletionStage<T> toCompletionStage(@Nullable T defaultItem) Signals the given default item when the upstream completes or signals the upstream error via aCompletionStage.Returns aFlowablewhich when subscribed to subscribes to thisCompletableand relays the terminal events to the downstreamFlow.Subscriber.toFuture()toMaybe()Converts thisCompletableinto aMaybe.final <@NonNull T>
@NonNull Observable<T> Returns anObservablewhich when subscribed to subscribes to thisCompletableand relays the terminal events to the downstreamObserver.toSingleDefault(@NonNull T completionValue) Converts thisCompletableinto aSinglewhich when thisCompletablecompletes normally, emits the given value throughonSuccess.static @NonNull CompletableunsafeCreate(@NonNull CompletableSource onSubscribe) Constructs aCompletableinstance by wrapping the given source callback without any safeguards; you should manage the lifecycle and response to downstream disposal.final @NonNull CompletableunsubscribeOn(@NonNull Scheduler scheduler) Returns aCompletablewhich makes sure when an observer disposes the subscription, thedispose()method is called on the specifiedScheduler.static <@NonNull R>
@NonNull Completableusing(@NonNull Supplier<@NonNull R> resourceSupplier, @NonNull Function<? super @NonNull R, ? extends CompletableSource> sourceSupplier, @NonNull Consumer<? super @NonNull R> resourceCleanup) Returns aCompletableinstance which manages a resource along with a customCompletableSourceinstance while the subscription is active.static <@NonNull R>
@NonNull Completableusing(@NonNull Supplier<@NonNull R> resourceSupplier, @NonNull Function<? super @NonNull R, ? extends CompletableSource> sourceSupplier, @NonNull Consumer<? super @NonNull R> resourceCleanup, boolean eager) Returns aCompletableinstance which manages a resource along with a customCompletableSourceinstance while the subscription is active and performs eager or lazy resource disposition.static @NonNull Completablewrap(@NonNull CompletableSource source)
-
Method Details
-
create
Creates a fresh CompletableSubject.- Returns:
- the new CompletableSubject instance
-
onSubscribe
Description copied from interface:CompletableObserverCalled once by theCompletableto set aDisposableon this instance which then can be used to cancel the subscription at any time.- Specified by:
onSubscribein interfaceCompletableObserver- Parameters:
d- theDisposableinstance to call dispose on for cancellation, not null
-
onError
Description copied from interface:CompletableObserverCalled once if the deferred computation 'throws' an exception.- Specified by:
onErrorin interfaceCompletableObserver- Parameters:
e- the exception, notnull.
-
onComplete
public void onComplete()Description copied from interface:CompletableObserverCalled once the deferred computation completes normally.- Specified by:
onCompletein interfaceCompletableObserver
-
subscribeActual
Description copied from class:CompletableImplement this method to handle the incomingCompletableObservers and perform the business logic in your operator.There is no need to call any of the plugin hooks on the current
Completableinstance or theCompletableObserver; all hooks and basic safeguards have been applied byCompletable.subscribe(CompletableObserver)before this method gets called.- Specified by:
subscribeActualin classCompletable- Parameters:
observer- theCompletableObserverinstance, nevernull
-
getThrowable
-
hasThrowable
public boolean hasThrowable()Returns true if this CompletableSubject has been terminated with an error.- Returns:
- true if this CompletableSubject has been terminated with an error
-
hasComplete
public boolean hasComplete()Returns true if this CompletableSubject has been completed.- Returns:
- true if this CompletableSubject has been completed
-
hasObservers
public boolean hasObservers()Returns true if this CompletableSubject has observers.- Returns:
- true if this CompletableSubject has observers
-