Class DefaultUniEmitter<T>
- java.lang.Object
-
- io.smallrye.mutiny.operators.uni.builders.DefaultUniEmitter<T>
-
- Type Parameters:
T- the type of item emitted by the emitter
- All Implemented Interfaces:
Cancellable,UniEmitter<T>,UniSubscription,org.reactivestreams.Subscription
public class DefaultUniEmitter<T> extends java.lang.Object implements UniEmitter<T>, UniSubscription
Implementation of the Uni Emitter. This implementation makes sure:- only the first event is propagated downstream
- termination action is called only once and then drop
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Requests theUnito cancel and clean up resources.voidcomplete(T item)Emits theitemevent downstream with the given (potentiallynull) item.voidfail(java.lang.Throwable failure)Emits thefailureevent downstream with the given exception.booleanisTerminated()UniEmitter<T>onTermination(java.lang.Runnable onTermination)Attaches a @{code termination} event handler invoked when the downstreamUniSubscriptionis cancelled, or when the emitter has emitted either anitemorfailureevent.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.smallrye.mutiny.subscription.UniSubscription
request
-
-
-
-
Method Detail
-
complete
public void complete(T item)
Description copied from interface:UniEmitterEmits theitemevent downstream with the given (potentiallynull) item.Calling this method multiple times or after the
UniEmitter.fail(Throwable)method has no effect.- Specified by:
completein interfaceUniEmitter<T>- Parameters:
item- the item, may benull
-
fail
public void fail(java.lang.Throwable failure)
Description copied from interface:UniEmitterEmits thefailureevent downstream with the given exception.Calling this method multiple times or after the
UniEmitter.complete(Object)method has no effect.- Specified by:
failin interfaceUniEmitter<T>- Parameters:
failure- the exception, must not benull
-
onTermination
public UniEmitter<T> onTermination(java.lang.Runnable onTermination)
Description copied from interface:UniEmitterAttaches a @{code termination} event handler invoked when the downstreamUniSubscriptionis cancelled, or when the emitter has emitted either anitemorfailureevent.This method allows cleanup resources once the emitter can be disposed (has reached a terminal state).
If the registration of the
onTerminationcallback is done after the termination, it invokes the callback immediately.- Specified by:
onTerminationin interfaceUniEmitter<T>- Parameters:
onTermination- the action to run on termination, must not benull- Returns:
- this emitter
-
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 interfaceorg.reactivestreams.Subscription- Specified by:
cancelin interfaceUniSubscription
-
isTerminated
public boolean isTerminated()
-
-