- All Implemented Interfaces:
Cancellable,ContextSupport,UniSubscriber<T>,UniSubscription,Flow.Subscription
UniSubscriber and UniSubscription making sure event handlers are only called once.-
Constructor Summary
ConstructorsConstructorDescriptionUniSerializedSubscriber(AbstractUni<T> upstream, UniSubscriber<? super T> subscriber) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Requests theUnito cancel and clean up resources.context()Provide a context.voidCalled if the computation of the item by the subscriberUnifailed.voidEvent 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.static <T> voidsubscribe(AbstractUni<T> source, UniSubscriber<? super T> subscriber) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.smallrye.mutiny.subscription.UniSubscription
request
-
Constructor Details
-
UniSerializedSubscriber
-
-
Method Details
-
subscribe
-
context
Description copied from interface:ContextSupportProvide a context.Since calls to this method shall only be triggered when a Mutiny pipeline uses a
withContextoperator, there is no need in general for caching the context value in a field of the implementing class. Exceptions include operators that have cross-subscriber semantics such as memoizers or broadcasters.This method is expected to be called once per
withContextoperator.- Specified by:
contextin interfaceContextSupport- Returns:
- the context, must not be
null.
-
onSubscribe
Description copied from interface:UniSubscriberEvent handler called once the subscribedUnihas taken into account the subscription. TheUnihave triggered the computation of the item.IMPORTANT:
UniSubscriber.onItem(Object)andUniSubscriber.onFailure(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,
UniSubscriber.onItem(Object)andUniSubscriber.onFailure(Throwable)won't be called
- Specified by:
onSubscribein interfaceUniSubscriber<T>- Parameters:
subscription- the subscription allowing to cancel the computation.
- Executor: Operate on no particular executor, except if
-
onItem
Description copied from interface:UniSubscriberEvent handler called once the item has been computed by the subscribedUni.IMPORTANT: this method will be only called once per subscription. If
UniSubscriber.onFailure(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.
- Specified by:
onItemin interfaceUniSubscriber<T>- Parameters:
item- the item, may benull.
- Executor: Operate on no particular executor, except if
-
onFailure
Description copied from interface:UniSubscriberCalled if the computation of the item by the subscriberUnifailed.IMPORTANT: this method will be only called once per subscription. If
UniSubscriber.onItem(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.
- Specified by:
onFailurein interfaceUniSubscriber<T>- Parameters:
throwable- the failure, cannot benull.
- Executor: Operate on no particular executor, except if
-
cancel
public void cancel()Description copied from interface:UniSubscriptionRequests theUnito cancel and clean up resources. If the item is retrieved after cancellation, it is not forwarded to the subscriber. If the cancellation happens after the delivery of the item, this call is ignored.Calling this method, emits the
cancellationevent upstream.- Specified by:
cancelin interfaceCancellable- Specified by:
cancelin interfaceFlow.Subscription- Specified by:
cancelin interfaceUniSubscription
-