Interface CompletionSubscriber<T,R>
- Type Parameters:
T
- The type of the elements that the subscriber consumes.R
- The type of the result that the subscriber emits.
- All Superinterfaces:
org.reactivestreams.Subscriber<T>
public interface CompletionSubscriber<T,R>
extends org.reactivestreams.Subscriber<T>
A subscriber that redeems a completion stage when it completes.
The result is provided through a CompletionStage
, which is redeemed when the subscriber receives a
completion or error signal, or otherwise cancels the stream.
The best way to instantiate one of these is using the of(org.reactivestreams.Subscriber<T>, java.util.concurrent.CompletionStage<R>)
factory method.
-
Method Summary
Modifier and TypeMethodDescriptionGet the completion stage.static <T,
R> CompletionSubscriber<T, R> of
(org.reactivestreams.Subscriber<T> subscriber, CompletionStage<R> completion) Create aCompletionSubscriber
by combining the given subscriber and completion stage.Methods inherited from interface org.reactivestreams.Subscriber
onComplete, onError, onNext, onSubscribe
-
Method Details
-
getCompletion
CompletionStage<R> getCompletion()Get the completion stage.This should be redeemed by the subscriber either when it cancels, or when it receives an
Subscriber.onComplete()
signal or anSubscriber.onError(Throwable)
signal. Generally, the redeemed value or error should be the result of consuming the stream.- Returns:
- The completion stage.
-
of
static <T,R> CompletionSubscriber<T,R> of(org.reactivestreams.Subscriber<T> subscriber, CompletionStage<R> completion) Create aCompletionSubscriber
by combining the given subscriber and completion stage. The objects passed to this method should not be associated with more than one stream instance.- Parameters:
subscriber
- The subscriber.completion
- The completion stage.- Returns:
- A completion subscriber.
-