Package org.reactivestreams
Interface Subscriber<T>
-
- Type Parameters:
T- the type of element signaled
- All Known Subinterfaces:
Processor<T,R>
public interface Subscriber<T>
Will receive call toonSubscribe(Subscription)once after passing an instance ofSubscribertoPublisher.subscribe(Subscriber).No further notifications will be received until
Subscription.request(long)is called.After signaling demand:
- One or more invocations of
onNext(Object)up to the maximum number defined bySubscription.request(long) - Single invocation of
onError(Throwable)oronComplete()which signals a terminal state after which no further events will be sent.
Demand can be signaled via
Subscription.request(long)whenever theSubscriberinstance is capable of handling more.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidonComplete()Successful terminal state.voidonError(java.lang.Throwable t)Failed terminal state.voidonNext(T t)Data notification sent by thePublisherin response to requests toSubscription.request(long).voidonSubscribe(Subscription s)Invoked after callingPublisher.subscribe(Subscriber).
-
-
-
Method Detail
-
onSubscribe
void onSubscribe(Subscription s)
Invoked after callingPublisher.subscribe(Subscriber).No data will start flowing until
Subscription.request(long)is invoked.It is the responsibility of this
Subscriberinstance to callSubscription.request(long)whenever more data is wanted.The
Publisherwill send notifications only in response toSubscription.request(long).- Parameters:
s- theSubscriptionthat allows requesting data viaSubscription.request(long)
-
onNext
void onNext(T t)
Data notification sent by thePublisherin response to requests toSubscription.request(long).- Parameters:
t- the element signaled
-
onError
void onError(java.lang.Throwable t)
Failed terminal state.No further events will be sent even if
Subscription.request(long)is invoked again.- Parameters:
t- the throwable signaled
-
onComplete
void onComplete()
Successful terminal state.No further events will be sent even if
Subscription.request(long)is invoked again.
-
-