public class SubscriberWithContext<T,C> extends Object implements org.reactivestreams.Subscriber<T>
Subscriber
with a typed stateful context. Some error isolation is also provided
(onSubscribe, onNext and onComplete error is forwarded to onError).Modifier and Type | Field and Description |
---|---|
protected C |
context |
protected org.reactivestreams.Subscriber<? super T> |
subscriber |
protected static AtomicIntegerFieldUpdater<SubscriberWithContext> |
TERMINAL_UPDATER |
Modifier | Constructor and Description |
---|---|
protected |
SubscriberWithContext(C context,
org.reactivestreams.Subscriber<? super T> subscriber) |
Modifier and Type | Method and Description |
---|---|
C |
context()
The stateful context C
|
static <T,C> SubscriberWithContext<T,C> |
create(org.reactivestreams.Subscriber<? super T> subscriber,
C context)
Attach a given arbitrary context (stateful information) to a
Subscriber , all Subscriber methods
will delegate properly. |
boolean |
isCancelled() |
void |
onComplete() |
void |
onError(Throwable t) |
void |
onNext(T t) |
void |
onSubscribe(org.reactivestreams.Subscription s) |
protected static final AtomicIntegerFieldUpdater<SubscriberWithContext> TERMINAL_UPDATER
protected final C context
protected final org.reactivestreams.Subscriber<? super T> subscriber
public static <T,C> SubscriberWithContext<T,C> create(org.reactivestreams.Subscriber<? super T> subscriber, C context)
Subscriber
, all Subscriber methods
will delegate properly.T
- Type of data sequenceC
- Type of attached stateful contextsubscriber
- the delegate subscriber to invoke on signalcontext
- the contextual state of any type to bind for later usepublic C context()
public void onSubscribe(org.reactivestreams.Subscription s)
onSubscribe
in interface org.reactivestreams.Subscriber<T>
public void onError(Throwable t)
onError
in interface org.reactivestreams.Subscriber<T>
public void onComplete()
onComplete
in interface org.reactivestreams.Subscriber<T>
public boolean isCancelled()
Copyright © 2017. All rights reserved.