Class RangePublisher
java.lang.Object
org.reactivestreams.example.unicast.RangePublisher
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classA Subscription implementation that holds the current downstream requested amount and responds to the downstream's request() and cancel() calls. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRangePublisher(int start, int count) Constructs a RangePublisher instance with the given start and count values that yields a sequence of [start, start + count). -
Method Summary
Modifier and TypeMethodDescriptionvoidsubscribe(Subscriber<? super Integer> subscriber) RequestPublisherto start streaming data.
-
Field Details
-
start
final int startThe starting value of the range. -
count
final int countThe number of items to emit.
-
-
Constructor Details
-
RangePublisher
public RangePublisher(int start, int count) Constructs a RangePublisher instance with the given start and count values that yields a sequence of [start, start + count).- Parameters:
start- the starting value of the rangecount- the number of items to emit
-
-
Method Details
-
subscribe
Description copied from interface:PublisherRequestPublisherto start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription.Each
Subscriptionwill work for only a singleSubscriber.A
Subscribershould only subscribe once to a singlePublisher.If the
Publisherrejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(Throwable).- Specified by:
subscribein interfacePublisher<Integer>- Parameters:
subscriber- theSubscriberthat will consume signals from thisPublisher
-