T - the value typepublic interface Signal<T> extends Supplier<T>, Consumer<Subscriber<? super T>>
| Modifier and Type | Method and Description |
|---|---|
default void |
accept(Subscriber<? super T> observer)
Propagate the signal represented by this
Signal instance to a
given Subscriber. |
static <T> Signal<T> |
complete()
Creates and returns a
Signal of variety Type.COMPLETE. |
static <T> Signal<T> |
complete(Context context)
|
static <T> Signal<T> |
error(Throwable e)
Creates and returns a
Signal of variety Type.FAILED, which holds
the error. |
static <T> Signal<T> |
error(Throwable e,
Context context)
Creates and returns a
Signal of variety Type.FAILED, which holds
the error and the Context associated with the erroring source. |
T |
get()
Retrieves the item associated with this (onNext) signal.
|
default Context |
getContext()
Deprecated.
use
getContextView() instead. To be removed in 3.5.0 |
ContextView |
getContextView()
Return the readonly
ContextView that is accessible by the time this Signal was
emitted. |
Subscription |
getSubscription()
Read the subscription associated with this (onSubscribe) signal.
|
Throwable |
getThrowable()
Read the error associated with this (onError) signal.
|
SignalType |
getType()
Read the type of this signal:
SignalType.ON_SUBSCRIBE,
SignalType.ON_NEXT, SignalType.ON_ERROR, or
SignalType.ON_COMPLETE |
default boolean |
hasError()
Read whether this signal is on error and carries the cause.
|
default boolean |
hasValue()
Has this signal an item associated with it ? (which only happens if it is an
(onNext) signal)
|
static boolean |
isComplete(Object o)
Check if an arbitrary Object represents a COMPLETE
Signal. |
static boolean |
isError(Object o)
Check if a arbitrary Object represents an ERROR
Signal. |
default boolean |
isOnComplete()
Indicates whether this signal represents an
onComplete event. |
default boolean |
isOnError()
Indicates whether this signal represents an
onError event. |
default boolean |
isOnNext()
Indicates whether this signal represents an
onNext event. |
default boolean |
isOnSubscribe()
Indicates whether this signal represents an
onSubscribe event. |
static <T> Signal<T> |
next(T t)
Creates and returns a
Signal of variety Type.NEXT, which holds
the value. |
static <T> Signal<T> |
next(T t,
Context context)
Creates and returns a
Signal of variety Type.NEXT, which holds
the value and the Context associated with the emitting source. |
static <T> Signal<T> |
subscribe(Subscription subscription)
Creates and returns a
Signal of variety Type.ON_SUBSCRIBE. |
static <T> Signal<T> |
subscribe(Subscription subscription,
Context context)
Creates and returns a
Signal of variety Type.ON_SUBSCRIBE, that
holds the Context associated with the subscribed source. |
static <T> Signal<T> complete()
Signal of variety Type.COMPLETE.
Note that this variant associates an empty Context with the Signal.
T - the value typeOnCompleted variety of Signalstatic <T> Signal<T> complete(Context context)
T - the value typecontext - the Context associated with the completing source.OnCompleted variety of Signalstatic <T> Signal<T> error(Throwable e)
Signal of variety Type.FAILED, which holds
the error.
Note that this variant associates an empty Context with the Signal.
T - the value typee - the error associated to the signalOnError variety of Signalstatic <T> Signal<T> error(Throwable e, Context context)
Signal of variety Type.FAILED, which holds
the error and the Context associated with the erroring source.T - the value typee - the error associated to the signalcontext - the Context associated with the erroring sourceOnError variety of Signalstatic <T> Signal<T> next(T t)
Signal of variety Type.NEXT, which holds
the value.
Note that this variant associates an empty Context with the Signal.
T - the value typet - the value item associated to the signalOnNext variety of Signalstatic <T> Signal<T> next(T t, Context context)
Signal of variety Type.NEXT, which holds
the value and the Context associated with the emitting source.T - the value typet - the value item associated to the signalcontext - the Context associated with the emitting sourceOnNext variety of Signalstatic <T> Signal<T> subscribe(Subscription subscription)
Signal of variety Type.ON_SUBSCRIBE.
Note that this variant associates an empty Context with the Signal.
T - the value typesubscription - the subscriptionOnSubscribe variety of Signalstatic <T> Signal<T> subscribe(Subscription subscription, Context context)
Signal of variety Type.ON_SUBSCRIBE, that
holds the Context associated with the subscribed source.T - the value typesubscription - the subscriptioncontext - the Context associated with the subscribed sourceOnSubscribe variety of Signalstatic boolean isComplete(Object o)
Signal.o - the object to checkstatic boolean isError(Object o)
Signal.o - the object to check@Nullable Throwable getThrowable()
@Nullable Subscription getSubscription()
default boolean hasValue()
default boolean hasError()
SignalType getType()
SignalType.ON_SUBSCRIBE,
SignalType.ON_NEXT, SignalType.ON_ERROR, or
SignalType.ON_COMPLETE@Deprecated default Context getContext()
getContextView() instead. To be removed in 3.5.0Context, or an empty one if no context is available.ContextView getContextView()
ContextView that is accessible by the time this Signal was
emitted.ContextView, or an empty one if no context is available.default boolean isOnError()
onError event.onError
eventdefault boolean isOnComplete()
onComplete event.onSubscribe
eventdefault boolean isOnSubscribe()
onSubscribe event.onSubscribe
eventdefault boolean isOnNext()
onNext event.onNext eventdefault void accept(Subscriber<? super T> observer)
Signal instance to a
given Subscriber.accept in interface Consumer<Subscriber<? super T>>observer - the Subscriber to play the Signal on