T - the type of item received by this subscriberpublic class UniCallbackSubscriber<T> extends Object implements UniSubscriber<T>, UniSubscription
UniSubscriber based on callbacks.
This implementation also implement UniSubscription to expose the cancel() method.| Constructor and Description |
|---|
UniCallbackSubscriber(Consumer<? super T> onResultCallback,
Consumer<? super Throwable> onFailureCallback)
Creates a
UniSubscriber consuming the item and failure of a
Uni. |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Requests the
Uni to cancel and clean up resources. |
void |
onFailure(Throwable t)
Called if the computation of the item by the subscriber
Uni failed. |
void |
onItem(T x)
Event handler called once the item has been computed by the subscribed
Uni. |
void |
onSubscribe(UniSubscription sub)
Event handler called once the subscribed
Uni has taken into account the subscription. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrequestpublic UniCallbackSubscriber(Consumer<? super T> onResultCallback, Consumer<? super Throwable> onFailureCallback)
UniSubscriber consuming the item and failure of a
Uni.onResultCallback - callback invoked on item event, must not be nullonFailureCallback - callback invoked on failure event, must not be nullpublic final void onSubscribe(UniSubscription sub)
UniSubscriberUni has taken into account the subscription. The Uni
have triggered the computation of the item.
IMPORTANT: UniSubscriber.onItem(Object) and UniSubscriber.onFailure(Throwable) would not be called
before the invocation of this method.
Uni.runSubscriptionOn(Executor) has been
calledUniSubscriber.onItem(Object) and
UniSubscriber.onFailure(Throwable) won't be calledonSubscribe in interface UniSubscriber<T>sub - the subscription allowing to cancel the computation.public final void onFailure(Throwable t)
UniSubscriberUni failed.
IMPORTANT: this method will be only called once per subscription. If
UniSubscriber.onItem(Object) is called, this method won't be called.
Uni.emitOn(java.util.concurrent.Executor) has been calledonFailure in interface UniSubscriber<T>t - the failure, cannot be null.public final void onItem(T x)
UniSubscriberUni.
IMPORTANT: this method will be only called once per subscription. If
UniSubscriber.onFailure(Throwable) is called, this method won't be called.
Uni.emitOn(java.util.concurrent.Executor) has been calledonItem in interface UniSubscriber<T>x - the item, may be null.public void cancel()
UniSubscriptionUni to 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 cancellation event upstream.
cancel in interface Cancellablecancel in interface UniSubscriptioncancel in interface org.reactivestreams.SubscriptionCopyright © 2019–2020 SmallRye. All rights reserved.