Package org.reactivestreams
Interface Subscription
-
public interface Subscription
ASubscriptionrepresents a one-to-one lifecycle of aSubscribersubscribing to aPublisher.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcancel()Request thePublisherto stop sending data and clean up resources.voidrequest(long n)No events will be sent by aPublisheruntil demand is signaled via this method.
-
-
-
Method Detail
-
request
void request(long n)
No events will be sent by aPublisheruntil 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
Publisheras "effectively unbounded".Whatever has been requested can be sent by the
Publisherso only signal demand for what can be safely handled.A
Publishercan send less than is requested if the stream ends but then must emit eitherSubscriber.onError(Throwable)orSubscriber.onComplete().- Parameters:
n- the strictly positive number of elements to requests to the upstreamPublisher
-
-