Subscriber implementation that lets the user
perform a request(long) and cancel() on it directly. As the targeted
use case is to manually handle requests, the hookOnSubscribe(Subscription) and
hookOnNext(Object) hooks are expected to be implemented, but they nonetheless
default to an unbounded request at subscription time. If you need to define a Context
for this BaseSubscriber, simply override its currentContext() method.
Override the other optional hooks hookOnComplete(),
hookOnError(Throwable) and hookOnCancel()
to customize the base behavior. You also have a termination hook,
hookFinally(SignalType).
Most of the time, exceptions triggered inside hooks are propagated to
onError(Throwable) (unless there is a fatal exception). The class is in the
reactor.core.publisher package, as this subscriber is tied to a single
org..
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static AtomicReferenceFieldUpdater | |
| pack-priv volatile Subscription |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final void | cancel()
Implements org. Publisher to stop sending data and clean up resources.
|
| public void | |
| protected void | hookFinally(SignalType
the type of termination event that triggered the hook
( type)SignalType#ON_ERROR, SignalType#ON_COMPLETE or
SignalType#CANCEL)Optional hook executed after any of the termination events (onError, onComplete, cancel). |
| protected void | hookOnCancel()
Optional hook executed when the subscription is cancelled by calling this
Subscriber's |
| protected void | |
| protected void | |
| protected void | |
| protected void | hookOnSubscribe(Subscription
the subscription to optionally process subscription)Hook for further processing of onSubscribe's Subscription. |
| public boolean | isDisposed()
Overrides default reactor. |
| public final void | |
| public final void | onError(Throwable
the throwable signaled t)Implements org. |
| public final void | onNext(T
the element signaled value)Implements org. Publisher in response to requests to Subscription#request(long).
|
| public final void | onSubscribe(Subscription
the s)Subscription that allows requesting data via Subscription#request(long)Implements reactor. onNext(Object) before
calling Subscription#request(long).
|
| public final void | request(long
the strictly positive number of elements to requests to the upstream n)PublisherImplements org. Publisher until demand is signaled via this method.
|
| public final void | |
| pack-priv void | |
| public String | |
| protected Subscription |
| S | back to summary |
|---|---|
| pack-priv static AtomicReferenceFieldUpdater<BaseSubscriber<T>, Subscription> S | |
| subscription | back to summary |
|---|---|
| pack-priv volatile Subscription subscription | |
| BaseSubscriber | back to summary |
|---|---|
| public BaseSubscriber() | |
| cancel | back to summary |
|---|---|
| public final void cancel() Implements org. Doc from org. Request the Data may still be sent to meet previously signalled demand after calling cancel.
| |
| dispose | back to summary |
|---|---|
| public void dispose() Implements reactor.
| |
| hookFinally | back to summary |
|---|---|
| protected void hookFinally(SignalType type) Optional hook executed after any of the termination events (onError, onComplete,
cancel). The hook is executed in addition to and after
| |
| hookOnCancel | back to summary |
|---|---|
| protected void hookOnCancel() Optional hook executed when the subscription is cancelled by calling this
Subscriber's | |
| hookOnComplete | back to summary |
|---|---|
| protected void hookOnComplete() Optional hook for completion processing. Defaults to doing nothing. | |
| hookOnError | back to summary |
|---|---|
| protected void hookOnError(Throwable throwable) Optional hook for error processing. Default is to call
| |
| hookOnNext | back to summary |
|---|---|
| protected void hookOnNext(T value) Hook for processing of onNext values. You can call Defaults to doing nothing.
| |
| hookOnSubscribe | back to summary |
|---|---|
| protected void hookOnSubscribe(Subscription subscription) Hook for further processing of onSubscribe's Subscription. Implement this method
to call Defaults to request unbounded Long.MAX_VALUE as in
| |
| isDisposed | back to summary |
|---|---|
| public boolean isDisposed() Overrides default reactor. Doc from reactor. Optionally return true when the resource or task is disposed. Implementations are not required to track disposition and as such may never return true even when disposed. However, they MUST only return true when there's a guarantee the resource or task is disposed.
| |
| onComplete | back to summary |
|---|---|
| public final void onComplete() Implements org. Doc from org. Successful terminal state.
No further events will be sent even if
| |
| onError | back to summary |
|---|---|
| public final void onError(Throwable t) Implements org. Doc from org. Failed terminal state.
No further events will be sent even if | |
| onNext | back to summary |
|---|---|
| public final void onNext(T value) Implements org. Doc from org. Data notification sent by the
| |
| onSubscribe | back to summary |
|---|---|
| public final void onSubscribe(Subscription s) Implements reactor. Doc from reactor. Implementors should initialize any state used by
Note that an invalid request
No data will start flowing until
It is the responsibility of this
The
| |
| request | back to summary |
|---|---|
| public final void request(long n) Implements org. Doc from org. No events will be sent by a
It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more,
it may be treated by the
Whatever has been requested can be sent by the
A | |
| requestUnbounded | back to summary |
|---|---|
| public final void requestUnbounded()
| |
| safeHookFinally | back to summary |
|---|---|
| pack-priv void safeHookFinally(SignalType type) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| upstream | back to summary |
|---|---|
| protected Subscription upstream() Return current
| |