Top Description Methods
org.reactivestreams

public Interface Subscription

Known Direct Implementers
org.reactivestreams.FlowAdapters.ReactiveToFlowSubscription

A Subscription represents a one-to-one lifecycle of a Subscriber subscribing to a Publisher.

It can only be used once by a single Subscriber.

It is used to both signal desire for data and cancel demand (and allow resource cleanup).

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Request the Publisher to stop sending data and clean up resources.

public void
request(long
the strictly positive number of elements to requests to the upstream Publisher
n
)

No events will be sent by a Publisher until demand is signaled via this method.

Method Detail

cancelback to summary
public void cancel()

Request the Publisher to stop sending data and clean up resources.

Data may still be sent to meet previously signalled demand after calling cancel.

requestback to summary
public void request(long n)

No events will be sent by a Publisher until demand is signaled via this method.

It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more, it may be treated by the Publisher as "effectively unbounded".

Whatever has been requested can be sent by the Publisher so only signal demand for what can be safely handled.

A Publisher can send less than is requested if the stream ends but then must emit either Subscriber#onError(Throwable) or Subscriber#onComplete().

Parameters
n:long

the strictly positive number of elements to requests to the upstream Publisher