Class MultiOnSubscribe<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiOnSubscribe<T>
-
- Type Parameters:
T
- the type of item
public class MultiOnSubscribe<T> extends java.lang.Object
Group to configure the action to execute when the observedMulti
sends aSubscription
. The downstream don't have a subscription yet. It will be passed once the configured action completes. For example:multi.onSubscription().invoke(sub -> System.out.println("subscribed")); // Delay the subscription by 1 second (or until an asynchronous action completes) multi.onSubscription().call(sub -> Uni.createFrom(1).onItem().delayIt().by(Duration.ofSecond(1)));
-
-
Constructor Summary
Constructors Constructor Description MultiOnSubscribe(Multi<T> upstream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Multi<T>
call(java.util.function.Function<? super org.reactivestreams.Subscription,Uni<?>> action)
Produces a newMulti
invoking the given @{code action} when thesubscription
event is received.Multi<T>
call(java.util.function.Supplier<Uni<?>> action)
Produces a newMulti
invoking the given @{code action} when thesubscription
event is received.Multi<T>
invoke(java.lang.Runnable callback)
Produces a newMulti
invoking the given callback when thesubscription
is received.Multi<T>
invoke(java.util.function.Consumer<? super org.reactivestreams.Subscription> callback)
Produces a newMulti
invoking the given callback when thesubscription
is received.
-
-
-
Method Detail
-
invoke
@CheckReturnValue public Multi<T> invoke(java.util.function.Consumer<? super org.reactivestreams.Subscription> callback)
Produces a newMulti
invoking the given callback when thesubscription
is 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
Multi
-
invoke
@CheckReturnValue public Multi<T> invoke(java.lang.Runnable callback)
Produces a newMulti
invoking the given callback when thesubscription
is 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
Multi
-
call
@CheckReturnValue public Multi<T> call(java.util.function.Function<? super org.reactivestreams.Subscription,Uni<?>> action)
Produces a newMulti
invoking the given @{code action} when thesubscription
event is received.Unlike
invoke(Consumer)
, the passed function returns aUni
. When the producedUni
sends the subscription, the function is called. The subscription event is passed downstream only when theUni
completes. If the producedUni
fails or if the function throws an exception, the failure is propagated downstream.- Parameters:
action
- the callback, must not benull
- Returns:
- the new
Multi
-
call
@CheckReturnValue public Multi<T> call(java.util.function.Supplier<Uni<?>> action)
Produces a newMulti
invoking the given @{code action} when thesubscription
event is received.Unlike
invoke(Consumer)
, the passed function returns aUni
. When the producedUni
sends the subscription, the supplier is called. The subscription event is passed downstream only when theUni
completes. If the producedUni
fails or if the function throws an exception, the failure is propagated downstream.- Parameters:
action
- the callback, must not benull
- Returns:
- the new
Multi
-
-