public abstract class BaseSubscriber<T> extends Object implements Subscriber<T>, Subscription, Trackable, Receiver, Disposable
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.
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
Publisher.
UNSPECIFIED| Constructor and Description |
|---|
BaseSubscriber() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel() |
void |
dispose()
Cancel or dispose the underlying task or resource.
|
protected void |
hookFinally(SignalType type)
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
cancel() method. |
protected void |
hookOnComplete()
Optional hook for completion processing.
|
protected void |
hookOnError(Throwable throwable)
Optional hook for error processing.
|
protected abstract void |
hookOnNext(T value)
Hook for processing of onNext values.
|
protected abstract void |
hookOnSubscribe(Subscription subscription)
Hook for further processing of onSubscribe's Subscription.
|
boolean |
isDisposed()
Optionally return true when the resource or task is disposed.
|
boolean |
isStarted()
Has this upstream started or "onSubscribed" ?
|
boolean |
isTerminated()
Has this upstream finished or "completed" / "failed" ?
|
void |
onComplete() |
void |
onError(Throwable t) |
void |
onNext(T value) |
void |
onSubscribe(Subscription s) |
void |
request(long n) |
String |
toString() |
Subscription |
upstream()
Return the direct source of data, Supports reference.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexpectedFromUpstream, getCapacity, getError, getPending, isCancelled, limit, requestedFromDownstreampublic Subscription upstream()
Receiverpublic boolean isStarted()
Trackablepublic boolean isDisposed()
DisposableisDisposed in interface Disposablepublic void dispose()
DisposableCall to this method is/should be idempotent.
dispose in interface Cancellationdispose in interface Disposableprotected abstract void hookOnSubscribe(Subscription subscription)
request(long) as an initial request. Values other than the
unbounded Long.MAX_VALUE imply that you'll also call request in
hookOnNext(Object).subscription - the subscription to optionally processprotected abstract void hookOnNext(T value)
request(long) here
to further request data from the source Publisher if
the initial request wasn't unbounded.value - the emitted value to processprotected void hookOnComplete()
protected void hookOnError(Throwable throwable)
Exceptions.errorCallbackNotImplemented(Throwable).throwable - the error to processprotected void hookOnCancel()
cancel() method. Defaults to doing nothing.protected void hookFinally(SignalType type)
hookOnError(Throwable),
hookOnComplete() and hookOnCancel() hooks, even if these callbacks
fail. Defaults to doing nothing. A failure of the callback will be caught by
Operators.onErrorDropped(Throwable).type - the type of termination event that triggered the hook
(SignalType.ON_ERROR, SignalType.ON_COMPLETE or
SignalType.CANCEL)public final void onSubscribe(Subscription s)
onSubscribe in interface Subscriber<T>public final void onNext(T value)
onNext in interface Subscriber<T>public final void onError(Throwable t)
onError in interface Subscriber<T>public final void onComplete()
onComplete in interface Subscriber<T>public final void request(long n)
request in interface Subscriptionpublic final void cancel()
cancel in interface Subscriptionpublic boolean isTerminated()
TrackableisTerminated in interface Trackable