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
&CompletableSource
whose outgoing signals to itsCompletableSource.Subscriber
s can be controlled.Behavior beyond simply delegating signals to the
CompletableSource.Subscriber
is accomplished by aFunction<Subscriber<? super T>, Subscriber<? super T>>
. ThisFunction
is invoked for everysubscribe(Subscriber)
invocation, and the result is used as the delegate for subsequentonSubscribe(Cancellable)
,onComplete()
, andonError(Throwable)
calls. SeeTestCompletable.Builder
for 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 class
TestCompletable.Builder
Allows for creatingTestCompletable
s 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 aTestCompletable
with the defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
handleSubscribe(CompletableSource.Subscriber subscriber)
Handles a subscriber to thisCompletable
.boolean
isSubscribed()
void
onComplete()
Completes theCompletableSource.Subscriber
.void
onError(java.lang.Throwable t)
void
onSubscribe(Cancellable cancellable)
Delivers theCancellable
to theCompletableSource.Subscriber
'sCompletableSource.Subscriber.onSubscribe(Cancellable)
.void
subscribe(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:
true
if thisTestCompletable
has been subscribed to,false
otherwise.
-
handleSubscribe
protected void handleSubscribe(CompletableSource.Subscriber subscriber)
Description copied from class:Completable
Handles a subscriber to thisCompletable
.This method is invoked internally by
Completable
for every call to theCompletable.subscribeInternal(CompletableSource.Subscriber)
method.- Specified by:
handleSubscribe
in classCompletable
- Parameters:
subscriber
- the subscriber.
-
subscribe
public void subscribe(CompletableSource.Subscriber subscriber)
Description copied from interface:CompletableSource
Subscribes to the outcome of thisCompletableSource
.- Specified by:
subscribe
in interfaceCompletableSource
- Parameters:
subscriber
- of the outcome.- See Also:
PublisherSource.subscribe(PublisherSource.Subscriber)
-
onSubscribe
public void onSubscribe(Cancellable cancellable)
Delivers theCancellable
to theCompletableSource.Subscriber
'sCompletableSource.Subscriber.onSubscribe(Cancellable)
.In the case of
auto-on-subscribe
, the delegatingCancellable
sent to theCompletableSource.Subscriber
by 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)
-
-