Package io.smallrye.mutiny.subscription
Interface UniSubscriber<T>
-
- Type Parameters:
T
- the expected type of item
- All Superinterfaces:
ContextSupport
- All Known Implementing Classes:
UniAssertSubscriber
,UniCallbackSubscriber
,UniDelegatingSubscriber
,UniMemoizeOp
,UniOperatorProcessor
,UniSerializedSubscriber
public interface UniSubscriber<T> extends ContextSupport
Will receive call toonSubscribe(UniSubscription)
once after passing an instance of thisUniSubscriber
toUniSubscribe.withSubscriber(UniSubscriber)
retrieved fromUni.subscribe()
. Unlike Reactive Streams Subscriber,UniSubscriber
does not request items.After subscription, it can receive:
- a item event triggering
onItem(Object)
. The item can benull
. - a failure event triggering
onFailure(Throwable)
which signals an error state.
Once this subscriber receives an item or failure event, no more events will be received.
Note that unlike in Reactive Streams, the value received in
onItem(Object)
can benull
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onFailure(java.lang.Throwable failure)
Called if the computation of the item by the subscriberUni
failed.void
onItem(T item)
Event handler called once the item has been computed by the subscribedUni
.void
onSubscribe(UniSubscription subscription)
Event handler called once the subscribedUni
has taken into account the subscription.-
Methods inherited from interface io.smallrye.mutiny.subscription.ContextSupport
context
-
-
-
-
Method Detail
-
onSubscribe
void onSubscribe(UniSubscription subscription)
Event handler called once the subscribedUni
has taken into account the subscription. TheUni
have triggered the computation of the item. IMPORTANT:onItem(Object)
andonFailure(Throwable)
would not be called before the invocation of this method.- Executor: Operate on no particular executor, except if
Uni.runSubscriptionOn(Executor)
has been called - Exception: Throwing an exception cancels the subscription,
onItem(Object)
andonFailure(Throwable)
won't be called
- Parameters:
subscription
- the subscription allowing to cancel the computation.
- Executor: Operate on no particular executor, except if
-
onItem
void onItem(T item)
Event handler called once the item has been computed by the subscribedUni
. IMPORTANT: this method will be only called once per subscription. IfonFailure(Throwable)
is called, this method won't be called.- Executor: Operate on no particular executor, except if
Uni.emitOn(java.util.concurrent.Executor)
has been called - Exception: Throwing an exception cancels the subscription.
- Parameters:
item
- the item, may benull
.
- Executor: Operate on no particular executor, except if
-
onFailure
void onFailure(java.lang.Throwable failure)
Called if the computation of the item by the subscriberUni
failed. IMPORTANT: this method will be only called once per subscription. IfonItem(Object)
is called, this method won't be called.- Executor: Operate on no particular executor, except if
Uni.emitOn(java.util.concurrent.Executor)
has been called - Exception: Throwing an exception cancels the subscription.
- Parameters:
failure
- the failure, cannot benull
.
- Executor: Operate on no particular executor, except if
-
-