public final class SubscriberFactory extends Object
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.:
PublisherFactory.forEach(sub ->
sub.onNext("hello")
).subscribe( SubscriberFactory.unbounded(
System.out::println
));
Constructor and Description |
---|
SubscriberFactory() |
Modifier and Type | Method and Description |
---|---|
static <T> org.reactivestreams.Subscriber<T> |
create(Consumer<org.reactivestreams.Subscription> subscriptionHandler)
Create a
Subscriber reacting onSubscribe with the passed Consumer |
static <T,C> org.reactivestreams.Subscriber<T> |
create(Function<org.reactivestreams.Subscription,C> subscriptionHandler,
BiConsumer<T,SubscriptionWithContext<C>> dataConsumer)
Create a
Subscriber reacting onSubscribe and onNext, eventually sharing a context. |
static <T,C> org.reactivestreams.Subscriber<T> |
create(Function<org.reactivestreams.Subscription,C> subscriptionHandler,
BiConsumer<T,SubscriptionWithContext<C>> dataConsumer,
BiConsumer<Throwable,C> errorConsumer)
Create a
Subscriber reacting onNext, onError. |
static <T,C> org.reactivestreams.Subscriber<T> |
create(Function<org.reactivestreams.Subscription,C> subscriptionHandler,
BiConsumer<T,SubscriptionWithContext<C>> dataConsumer,
BiConsumer<Throwable,C> errorConsumer,
Consumer<C> completeConsumer)
Create a
Subscriber reacting onNext, onSubscribe, onError, onComplete with the passed BiConsumer . |
static <T> org.reactivestreams.Subscriber<T> |
unbounded()
Create a
Subscriber that will will automatically request Long.MAX_VALUE onSubscribe. |
static <T> org.reactivestreams.Subscriber<T> |
unbounded(BiConsumer<T,SubscriptionWithContext<Void>> dataConsumer)
Create a
Subscriber reacting onNext. |
static <T> org.reactivestreams.Subscriber<T> |
unbounded(BiConsumer<T,SubscriptionWithContext<Void>> dataConsumer,
Consumer<Throwable> errorConsumer)
Create a
Subscriber reacting onNext and onError. |
static <T> org.reactivestreams.Subscriber<T> |
unbounded(BiConsumer<T,SubscriptionWithContext<Void>> dataConsumer,
Consumer<Throwable> errorConsumer,
Consumer<Void> completeConsumer)
Create a
Subscriber reacting onNext, onError and onComplete. |
public static <T> org.reactivestreams.Subscriber<T> create(Consumer<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,C> org.reactivestreams.Subscriber<T> create(Function<org.reactivestreams.Subscription,C> subscriptionHandler, BiConsumer<T,SubscriptionWithContext<C>> dataConsumer)
Subscriber
reacting onSubscribe and onNext, eventually sharing a context.
The argument subscriptionHandler
is executed once onSubscribe to generate a context shared by every
onNext calls.T
- The type of the data sequenceC
- The type of contextual information to be read by the requestConsumersubscriptionHandler
- A Function
called once for every new subscription returning an immutable
contextdataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscription
(IO connection...)public static <T,C> org.reactivestreams.Subscriber<T> create(Function<org.reactivestreams.Subscription,C> subscriptionHandler, BiConsumer<T,SubscriptionWithContext<C>> dataConsumer, BiConsumer<Throwable,C> errorConsumer)
Subscriber
reacting onNext, onError.
The argument subscriptionHandler
is executed onSubscribe to
request initial data on the subscription and eventually generate a context shared by every
request calls.
T
- The type of the data sequenceC
- The type of contextual information to be read by the requestConsumersubscriptionHandler
- A Function
called once for every new subscription returning an immutable
contextdataConsumer
- A BiConsumer
with left argument onNext data and right argument upstream
subscription
(IO connection...)errorConsumer
- A Consumer
called onErrorpublic static <T> org.reactivestreams.Subscriber<T> unbounded()
Subscriber
that will will automatically request Long.MAX_VALUE onSubscribe.T
- The type of the data sequencepublic static <T> org.reactivestreams.Subscriber<T> unbounded(BiConsumer<T,SubscriptionWithContext<Void>> 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(BiConsumer<T,SubscriptionWithContext<Void>> dataConsumer, Consumer<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(BiConsumer<T,SubscriptionWithContext<Void>> dataConsumer, Consumer<Throwable> errorConsumer, Consumer<Void> 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 Consumer
called onComplete with the actual context if anypublic static <T,C> org.reactivestreams.Subscriber<T> create(Function<org.reactivestreams.Subscription,C> subscriptionHandler, BiConsumer<T,SubscriptionWithContext<C>> dataConsumer, BiConsumer<Throwable,C> errorConsumer, Consumer<C> 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 sequenceC
- The type of contextual information to be read by the requestConsumerdataConsumer
- 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 error as left operand and a given
context as right operandcompleteConsumer
- A Consumer
called onComplete with the actual context if anyCopyright © 2016. All rights reserved.