public abstract class BaseSubscriber<T> extends java.lang.Object implements CoreSubscriber<T>, org.reactivestreams.Subscription, 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, but they nonetheless
default to an unbounded request at subscription time. If you need to define a Context
for this BaseSubscriber
, simply override its CoreSubscriber.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
Publisher
.
Disposable.Composite, Disposable.Swap
构造器和说明 |
---|
BaseSubscriber() |
限定符和类型 | 方法和说明 |
---|---|
void |
cancel() |
void |
dispose()
|
boolean |
isDisposed()
Optionally return true when the resource or task is disposed.
|
void |
onComplete() |
void |
onError(java.lang.Throwable t) |
void |
onNext(T value) |
void |
onSubscribe(org.reactivestreams.Subscription s)
Implementors should initialize any state used by
Subscriber.onNext(Object) before
calling Subscription.request(long) . |
void |
request(long n) |
void |
requestUnbounded()
Request an unbounded amount. |
java.lang.String |
toString() |
currentContext
public boolean isDisposed()
Disposable
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.
isDisposed
在接口中 Disposable
public void dispose()
dispose
在接口中 Disposable
public final void onSubscribe(org.reactivestreams.Subscription s)
CoreSubscriber
Subscriber.onNext(Object)
before
calling Subscription.request(long)
. Should further onNext
related
state modification occur, thread-safety will be required.
Note that an invalid request <= 0
will not produce an onError and
will simply be ignored or reported through a debug-enabled
Logger
.
onSubscribe
在接口中 org.reactivestreams.Subscriber<T>
onSubscribe
在接口中 CoreSubscriber<T>
public final void onError(java.lang.Throwable t)
onError
在接口中 org.reactivestreams.Subscriber<T>
public final void onComplete()
onComplete
在接口中 org.reactivestreams.Subscriber<T>
public final void request(long n)
request
在接口中 org.reactivestreams.Subscription
public final void requestUnbounded()
Request
an unbounded amount.public final void cancel()
cancel
在接口中 org.reactivestreams.Subscription
public java.lang.String toString()
toString
在类中 java.lang.Object