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 Type
    Method
    Description
    Get the completion stage.
    static <T, R> CompletionSubscriber<T,R>
    of(org.reactivestreams.Subscriber<T> subscriber, CompletionStage<R> completion)
    Create a CompletionSubscriber 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 an Subscriber.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 a CompletionSubscriber by combining the given subscriber and completion stage. The objects passed to this method should not be associated with more than one stream instance.

      The returned CompletionSubscriber will delegate calls from the Subscriber interface to subscriber and will return completion from getCompletion().

      It is the callers responsibility to ensure that completion is completed with the correct value when subscriber terminates.

      Parameters:
      subscriber - The subscriber.
      completion - The completion stage.
      Returns:
      A completion subscriber.