- Type Parameters:
T- the type of item
Uni sends a UniSubscription.
The downstream don't have a subscription yet. It will be passed once the configured action completes.
Example:
uni.onSubscription().invoke(sub -> System.out.println("subscribed"));
// Delay the subscription by 1 second (or until an asynchronous action completes)
uni.onSubscription().call(sub -> Uni.createFrom(1).onItem().delayIt().by(Duration.ofSecond(1)));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall(Function<? super UniSubscription, Uni<?>> action) Produces a newUniinvoking the given @{code action} when thesubscriptionevent is received.Produces a newUniinvoking the given @{code action} when thesubscriptionevent is received.Produces a newUniinvoking the given callback when thesubscriptionis received.invoke(Consumer<? super UniSubscription> callback) Produces a newUniinvoking the given callback when thesubscriptionis received.
-
Constructor Details
-
UniOnSubscribe
-
-
Method Details
-
invoke
Produces a newUniinvoking the given callback when thesubscriptionis received.The callback in invoked before passing a subscription event downstream. If the callback throws an exception, the downstream receives a subscription and the failure immediately.
- Parameters:
callback- the callback, must not benull.- Returns:
- the new
Uni
-
invoke
Produces a newUniinvoking the given callback when thesubscriptionis received.The callback in invoked before passing a subscription event downstream. If the callback throws an exception, the downstream receives a subscription and the failure immediately.
- Parameters:
callback- the callback, must not benull.- Returns:
- the new
Uni
-
call
Produces a newUniinvoking the given @{code action} when thesubscriptionevent is received.Unlike
invoke(Consumer), the passed function returns aUni. When the producedUnisends the subscription, the function is called. The subscription event is passed downstream only when theUnicompletes. If the producedUnifails or if the function throws an exception, the failure is propagated downstream.- Parameters:
action- the callback, must not benull- Returns:
- the new
Uni
-
call
Produces a newUniinvoking the given @{code action} when thesubscriptionevent is received.Unlike
invoke(Consumer), the passed function returns aUni. When the producedUnisends the subscription, the function is called. The subscription event is passed downstream only when theUnicompletes. If the producedUnifails or if the function throws an exception, the failure is propagated downstream.- Parameters:
action- the callback, must not benull- Returns:
- the new
Uni
-