Package io.servicetalk.concurrent.api
Class TestCompletable
- java.lang.Object
-
- io.servicetalk.concurrent.api.Completable
-
- io.servicetalk.concurrent.api.TestCompletable
-
- All Implemented Interfaces:
CompletableSource
public final class TestCompletable extends Completable implements CompletableSource
ACompletable&CompletableSourcewhose outgoing signals to itsCompletableSource.Subscribers can be controlled.Behavior beyond simply delegating signals to the
CompletableSource.Subscriberis accomplished by aFunction<Subscriber<? super T>, Subscriber<? super T>>. ThisFunctionis invoked for everysubscribe(Subscriber)invocation, and the result is used as the delegate for subsequentonSubscribe(Cancellable),onComplete(), andonError(Throwable)calls. SeeTestCompletable.Builderfor more information.Defaults
- Allows sequential but not concurrent subscribers.
- Sends
onSubscribe(Cancellable)automatically when subscribed to.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTestCompletable.BuilderAllows for creatingTestCompletables with non-default settings.-
Nested classes/interfaces inherited from interface io.servicetalk.concurrent.CompletableSource
CompletableSource.Processor, CompletableSource.Subscriber
-
-
Constructor Summary
Constructors Constructor Description TestCompletable()Create aTestCompletablewith the defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidhandleSubscribe(CompletableSource.Subscriber subscriber)Handles a subscriber to thisCompletable.booleanisSubscribed()voidonComplete()Completes theCompletableSource.Subscriber.voidonError(java.lang.Throwable t)voidonSubscribe(Cancellable cancellable)Delivers theCancellableto theCompletableSource.Subscriber'sCompletableSource.Subscriber.onSubscribe(Cancellable).voidsubscribe(CompletableSource.Subscriber subscriber)Subscribes to the outcome of thisCompletableSource.-
Methods inherited from class io.servicetalk.concurrent.api.Completable
afterCancel, afterFinally, afterFinally, afterOnComplete, afterOnError, afterOnSubscribe, afterSubscriber, amb, amb, ambWith, anyOf, anyOf, beforeCancel, beforeFinally, beforeFinally, beforeOnComplete, beforeOnError, beforeOnSubscribe, beforeSubscriber, completed, concat, concat, concat, defer, failed, fromFuture, fromRunnable, fromStage, idleTimeout, idleTimeout, idleTimeout, idleTimeout, liftAsync, liftSync, merge, merge, merge, merge, mergeAll, mergeAll, mergeAll, mergeAll, mergeAllDelayError, mergeAllDelayError, mergeAllDelayError, mergeAllDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, never, onErrorResume, publishAndSubscribeOn, publishAndSubscribeOnOverride, publishOn, publishOnOverride, repeat, repeatWhen, retry, retryWhen, subscribe, subscribe, subscribeInternal, subscribeOn, subscribeOnOverride, subscribeShareContext, toCompletionStage, toFuture, toPublisher, toSingle, whenCancel, whenFinally, whenFinally, whenOnComplete, whenOnError, whenOnSubscribe, whenSubscriber
-
-
-
-
Method Detail
-
isSubscribed
public boolean isSubscribed()
- Returns:
trueif thisTestCompletablehas been subscribed to,falseotherwise.
-
handleSubscribe
protected void handleSubscribe(CompletableSource.Subscriber subscriber)
Description copied from class:CompletableHandles a subscriber to thisCompletable.This method is invoked internally by
Completablefor every call to theCompletable.subscribeInternal(CompletableSource.Subscriber)method.- Specified by:
handleSubscribein classCompletable- Parameters:
subscriber- the subscriber.
-
subscribe
public void subscribe(CompletableSource.Subscriber subscriber)
Description copied from interface:CompletableSourceSubscribes to the outcome of thisCompletableSource.- Specified by:
subscribein interfaceCompletableSource- Parameters:
subscriber- of the outcome.- See Also:
PublisherSource.subscribe(PublisherSource.Subscriber)
-
onSubscribe
public void onSubscribe(Cancellable cancellable)
Delivers theCancellableto theCompletableSource.Subscriber'sCompletableSource.Subscriber.onSubscribe(Cancellable).In the case of
auto-on-subscribe, the delegatingCancellablesent to theCompletableSource.Subscriberby the auto-on-subscribe will switch tocancellable.- Parameters:
cancellable- theCancellable
-
onComplete
public void onComplete()
Completes theCompletableSource.Subscriber.
-
onError
public void onError(java.lang.Throwable t)
- Parameters:
t- the error to deliver.- See Also:
CompletableSource.Subscriber.onError(Throwable)
-
-