Class RangePublisher
- java.lang.Object
-
- org.reactivestreams.example.unicast.RangePublisher
-
- All Implemented Interfaces:
Publisher<java.lang.Integer>
public final class RangePublisher extends java.lang.Object implements Publisher<java.lang.Integer>
A synchronous implementation of thePublisher
that can be subscribed to multiple times and each individual subscription will receive range of monotonically increasing integer values on demand.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
RangePublisher.RangeSubscription
A Subscription implementation that holds the current downstream requested amount and responds to the downstream's request() and cancel() calls.
-
Constructor Summary
Constructors Constructor Description RangePublisher(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
subscribe(Subscriber<? super java.lang.Integer> subscriber)
RequestPublisher
to start streaming data.
-
-
-
Method Detail
-
subscribe
public void subscribe(Subscriber<? super java.lang.Integer> subscriber)
Description copied from interface:Publisher
RequestPublisher
to start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
.Each
Subscription
will work for only a singleSubscriber
.A
Subscriber
should only subscribe once to a singlePublisher
.If the
Publisher
rejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(Throwable)
.- Specified by:
subscribe
in interfacePublisher<java.lang.Integer>
- Parameters:
subscriber
- theSubscriber
that will consume signals from thisPublisher
-
-