Package io.smallrye.mutiny.subscription
Interface UniSubscriber<T>
-
- Type Parameters:
T- the expected type of item
- All Known Implementing Classes:
UniAssertSubscriber,UniCallbackSubscriber,UniDelegatingSubscriber,UniMemoizeOp,UniOperatorProcessor,UniSerializedSubscriber
public interface UniSubscriber<T>Will receive call toonSubscribe(UniSubscription)once after passing an instance of thisUniSubscribertoUniSubscribe.withSubscriber(UniSubscriber)retrieved fromUni.subscribe(). Unlike Reactive Streams Subscriber,UniSubscriberdoes 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 voidonFailure(java.lang.Throwable failure)Called if the computation of the item by the subscriberUnifailed.voidonItem(T item)Event handler called once the item has been computed by the subscribedUni.voidonSubscribe(UniSubscription subscription)Event handler called once the subscribedUnihas taken into account the subscription.
-
-
-
Method Detail
-
onSubscribe
void onSubscribe(UniSubscription subscription)
Event handler called once the subscribedUnihas taken into account the subscription. TheUnihave 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 subscriberUnifailed. 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
-
-