public enum Subscribers extends java.lang.Enum<Subscribers>
Subscriber
factory which callbacks on start, onNext, onError and shutdown
The Publisher will directly forward all the signals passed to the subscribers and complete when onComplete is called.
Create such publisher with the provided factory, E.g.:
Flux.just("hello")
.subscribe( Subscribers.unbounded(System.out::println) );
Modifier and Type | Method and Description |
---|---|
static <T> LambdaSubscriber<T> |
bounded(int prefetch,
java.util.function.Consumer<? super T> callback)
Create a bounded
LambdaSubscriber that will keep a maximum in-flight items running. |
static <T> LambdaSubscriber<T> |
bounded(int prefetch,
java.util.function.Consumer<? super T> callback,
java.util.function.Consumer<? super java.lang.Throwable> errorCallback,
java.lang.Runnable completeCallback)
Create a bounded
LambdaSubscriber that will keep a maximum in-flight items running. |
static <T> org.reactivestreams.Subscriber<T> |
consumer(java.util.function.Consumer<? super T> dataConsumer)
Create a
Subscriber reacting onNext. |
static <T> org.reactivestreams.Subscriber<T> |
consumer(java.util.function.Consumer<? super T> dataConsumer,
java.util.function.Consumer<? super java.lang.Throwable> errorConsumer)
Create a
Subscriber reacting onNext and onError. |
static <T> org.reactivestreams.Subscriber<T> |
consumer(java.util.function.Consumer<? super T> dataConsumer,
java.util.function.Consumer<? super java.lang.Throwable> errorConsumer,
java.lang.Runnable completeConsumer)
Create a
Subscriber reacting onNext, onError and onComplete. |
static <T> org.reactivestreams.Subscriber<T> |
create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler)
Create a
Subscriber reacting onSubscribe with the passed Consumer |
static <T> org.reactivestreams.Subscriber<T> |
create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler,
java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer)
Create a
Subscriber reacting onSubscribe and onNext |
static <T> org.reactivestreams.Subscriber<T> |
create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler,
java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer,
java.util.function.Consumer<? super java.lang.Throwable> errorConsumer)
Create a
Subscriber reacting onNext, onError. |
static <T> org.reactivestreams.Subscriber<T> |
create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler,
java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer,
java.util.function.Consumer<? super java.lang.Throwable> errorConsumer,
java.lang.Runnable completeConsumer)
Create a
Subscriber reacting onNext, onSubscribe, onError, onComplete with the passed BiConsumer . |
static <T> org.reactivestreams.Subscriber<T> |
serialize(org.reactivestreams.Subscriber<? super T> subscriber)
Safely gate a
Subscriber by a serializing Subscriber . |
static <T> org.reactivestreams.Subscriber<T> |
unbounded()
Create a
Subscriber that will automatically request Long.MAX_VALUE onSubscribe. |
static <T> org.reactivestreams.Subscriber<T> |
unbounded(java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer)
Create a
Subscriber reacting onNext. |
static <T> org.reactivestreams.Subscriber<T> |
unbounded(java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer,
java.util.function.Consumer<? super java.lang.Throwable> errorConsumer)
Create a
Subscriber reacting onNext and onError. |
static <T> org.reactivestreams.Subscriber<T> |
unbounded(java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer,
java.util.function.Consumer<? super java.lang.Throwable> errorConsumer,
java.lang.Runnable completeConsumer)
Create a
Subscriber reacting onNext, onError and onComplete. |
static Subscribers |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Subscribers[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static Subscribers[] values()
for (Subscribers c : Subscribers.values()) System.out.println(c);
public static Subscribers valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static <T> LambdaSubscriber<T> bounded(int prefetch, java.util.function.Consumer<? super T> callback)
LambdaSubscriber
that will keep a maximum in-flight items running.
The prefetch strategy works with a first request N, then when 25% of N is left to be received on
onNext, request N x 0.75.
T
- the consumed sequence typeprefetch
- the in-flight capacity used to request source Publisher
callback
- an onNext Consumer
callbackLambdaSubscriber
public static <T> LambdaSubscriber<T> bounded(int prefetch, java.util.function.Consumer<? super T> callback, java.util.function.Consumer<? super java.lang.Throwable> errorCallback, java.lang.Runnable completeCallback)
LambdaSubscriber
that will keep a maximum in-flight items running.
The prefetch strategy works with a first request N, then when 25% of N is left to be received on
onNext, request N x 0.75.
T
- the consumed sequence typeprefetch
- the in-flight capacity used to request source Publisher
callback
- an onNext Consumer
callbackerrorCallback
- an onError Consumer
callbackcompleteCallback
- an onComplete Consumer
callbackLambdaSubscriber
public static <T> org.reactivestreams.Subscriber<T> consumer(java.util.function.Consumer<? super T> dataConsumer)
Subscriber
reacting onNext. The subscriber will automatically
request Long.MAX_VALUE onSubscribe.T
- The type of the data sequencedataConsumer
- A Consumer
with argument onNext datapublic static <T> org.reactivestreams.Subscriber<T> consumer(java.util.function.Consumer<? super T> dataConsumer, java.util.function.Consumer<? super java.lang.Throwable> errorConsumer)
Subscriber
reacting onNext and onError. The subscriber will automatically
request Long.MAX_VALUE onSubscribe.T
- The type of the data sequencedataConsumer
- A Consumer
with argument onNext dataerrorConsumer
- A Consumer
called onErrorpublic static <T> org.reactivestreams.Subscriber<T> consumer(java.util.function.Consumer<? super T> dataConsumer, java.util.function.Consumer<? super java.lang.Throwable> errorConsumer, java.lang.Runnable completeConsumer)
Subscriber
reacting onNext, onError and onComplete. The subscriber will automatically
request Long.MAX_VALUE onSubscribe.
T
- The type of the data sequencedataConsumer
- A Consumer
with argument onNext dataerrorConsumer
- A Consumer
called onErrorcompleteConsumer
- A Runnable
called onComplete with the actual context if anypublic static <T> org.reactivestreams.Subscriber<T> create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler)
Subscriber
reacting onSubscribe with the passed Consumer
T
- The type of the data sequencesubscriptionHandler
- A Consumer
called once for every new subscription returning
(IO connection...)public static <T> org.reactivestreams.Subscriber<T> create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler, java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer)
Subscriber
reacting onSubscribe and onNextT
- The type of the data sequencesubscriptionHandler
- A Consumer
called once for every new
subscription
contextdataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscriptionpublic static <T> org.reactivestreams.Subscriber<T> create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler, java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer, java.util.function.Consumer<? super java.lang.Throwable> errorConsumer)
Subscriber
reacting onNext, onError.
T
- The type of the data sequencesubscriptionHandler
- A Consumer
called once for every new
subscription
contextdataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscriptionerrorConsumer
- A Consumer
called onErrorpublic static <T> org.reactivestreams.Subscriber<T> create(java.util.function.Consumer<? super org.reactivestreams.Subscription> subscriptionHandler, java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer, java.util.function.Consumer<? super java.lang.Throwable> errorConsumer, java.lang.Runnable completeConsumer)
Subscriber
reacting onNext, onSubscribe, onError, onComplete with the passed BiConsumer
.
The argument subscriptionHandler
is executed once by new subscriber to generate a context shared by
every
request calls.
The argument shutdownConsumer
is executed once by subscriber termination event (cancel, onComplete,
onError).T
- The type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscriptionsubscriptionHandler
- A Function
called once for every new subscription returning an immutable
context
(IO connection...)errorConsumer
- A BiConsumer
called onError with the actual errorcompleteConsumer
- A Runnable
called onComplete with the actualpublic static <T> org.reactivestreams.Subscriber<T> serialize(org.reactivestreams.Subscriber<? super T> subscriber)
Subscriber
by a serializing Subscriber
.
Serialization uses thread-stealing and a potentially unbounded queue that might starve a calling thread if
races are too important and
Subscriber
is slower.
T
- the relayed typesubscriber
- the subscriber to wrapSubscriber
public static <T> org.reactivestreams.Subscriber<T> unbounded()
Subscriber
that will automatically request Long.MAX_VALUE onSubscribe.T
- The type of the data sequencepublic static <T> org.reactivestreams.Subscriber<T> unbounded(java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer)
Subscriber
reacting onNext. The subscriber will automatically
request Long.MAX_VALUE onSubscribe.T
- The type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream subscriptionpublic static <T> org.reactivestreams.Subscriber<T> unbounded(java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer, java.util.function.Consumer<? super java.lang.Throwable> errorConsumer)
Subscriber
reacting onNext and onError. The subscriber will automatically
request Long.MAX_VALUE onSubscribe.T
- The type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscriptionerrorConsumer
- A Consumer
called onErrorpublic static <T> org.reactivestreams.Subscriber<T> unbounded(java.util.function.BiConsumer<? super T,? super org.reactivestreams.Subscription> dataConsumer, java.util.function.Consumer<? super java.lang.Throwable> errorConsumer, java.lang.Runnable completeConsumer)
Subscriber
reacting onNext, onError and onComplete. The subscriber will automatically
request Long.MAX_VALUE onSubscribe.
The argument subscriptionHandler
is executed once by new subscriber to generate a context shared by
every
request calls.
T
- The type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscriptionerrorConsumer
- A Consumer
called onErrorcompleteConsumer
- A Runnable
called onComplete