T - the type of item emitted by the Unipublic class UniOnEvent<T> extends Object
Uni or by
a UniSubscriber| Constructor and Description |
|---|
UniOnEvent(Uni<T> upstream) |
| Modifier and Type | Method and Description |
|---|---|
Uni<T> |
cancellation(Runnable runnable)
Attaches an action executed when a subscription is cancelled.
|
UniOnFailure<T> |
failure()
Like
failure(Predicate) but applied to all failures fired by the upstream uni. |
UniOnFailure<T> |
failure(Class<? extends Throwable> typeOfFailure)
Configures a type of failure filtering the failures on which the behavior (specified with the returned
UniOnFailure) is applied. |
UniOnFailure<T> |
failure(Predicate<? super Throwable> predicate)
Configures a predicate filtering the failures on which the behavior (specified with the returned
UniOnFailure) is applied. |
UniOnItem<T> |
item()
Configures the action to execute when the observed
Uni emits the item (potentially null). |
Uni<T> |
subscribed(Consumer<? super UniSubscription> consumer)
Attaches an action executed when the
Uni has received a UniSubscription from upstream. |
Uni<T> |
termination(Functions.TriConsumer<T,Throwable,Boolean> consumer)
Attaches an action that is executed when the
Uni emits an item or a failure or when the subscriber
cancels the subscription. |
Uni<T> |
termination(Runnable action)
Attaches an action that is executed when the
Uni emits an item or a failure or when the subscriber
cancels the subscription. |
public Uni<T> subscribed(Consumer<? super UniSubscription> consumer)
Uni has received a UniSubscription from upstream.
The downstream does not have received the subscription yet. It will be done once the action completes.
This method is not intended to cancel the subscription. It's the responsibility of the subscriber to do so.
consumer - the callback, must not be nullUnipublic Uni<T> cancellation(Runnable runnable)
runnable - the callback, must not be nullUnipublic Uni<T> termination(Functions.TriConsumer<T,Throwable,Boolean> consumer)
Uni emits an item or a failure or when the subscriber
cancels the subscription.consumer - the consumer receiving the item, the failure and a boolean indicating whether the termination
is due to a cancellation (the 2 first parameters would be null in this case). Must not
be null If the second parameter (the failure) is not null, the first is
necessary null and the third is necessary false as it indicates a termination
due to a failure.Unipublic Uni<T> termination(Runnable action)
Uni emits an item or a failure or when the subscriber
cancels the subscription. Unlike termination(Functions.TriConsumer), the callback does not receive
the item, failure or cancellation.action - the action to run, must not be nullUnipublic UniOnItem<T> item()
Uni emits the item (potentially null).
Examples:
Uni<T> uni = ...;
uni.onItem().apply(x -> ...); // Map to another item
uni.onItem().produceUni(x -> ...); // Map to another Uni (flatMap)
Uni.ifNoItem()public UniOnFailure<T> failure()
failure(Predicate) but applied to all failures fired by the upstream uni.
It allows configuring the on failure behavior (recovery, retry...).public UniOnFailure<T> failure(Predicate<? super Throwable> predicate)
UniOnFailure) is applied.
For instance, to only when an IOException is fired as failure you can use:
uni.onFailure(IOException.class).recoverWithItem("hello")
The fallback value (hello) will only be used if the upstream uni fire a failure of type
IOException.*
predicate - the predicate, null means applied to all failurespublic UniOnFailure<T> failure(Class<? extends Throwable> typeOfFailure)
UniOnFailure) is applied.
For instance, to only when an IOException is fired as failure you can use:
uni.onFailure(IOException.class).recoverWithItem("hello")
The fallback value (hello) will only be used if the upstream uni fire a failure of type
IOException.*
typeOfFailure - the class of exception, must not be nullCopyright © 2019–2020 SmallRye. All rights reserved.