T - the type of itempublic class MultiOnSubscribe<T> extends Object
Multi sends a Subscription.
The downstream don't have a subscription yet. It will be passed once the configured action completes.
For example:
multi.onSubscribe().invoke(sub -> System.out.println("subscribed"));
// Delay the subscription by 1 second (or until an asynchronous action completes)
multi.onSubscribe().invokeUni(sub -> Uni.createFrom(1).onItem().delayIt().by(Duration.ofSecond(1)));
| Constructor and Description |
|---|
MultiOnSubscribe(Multi<T> upstream) |
| Modifier and Type | Method and Description |
|---|---|
Multi<T> |
invoke(Consumer<? super org.reactivestreams.Subscription> callback)
Produces a new
Multi invoking the given callback when the subscription is received. |
Multi<T> |
invokeUni(Function<? super org.reactivestreams.Subscription,Uni<?>> action)
Produces a new
Multi invoking the given @{code action} when the subscription event is received. |
public Multi<T> invoke(Consumer<? super org.reactivestreams.Subscription> callback)
Multi invoking the given callback when the subscription 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.
callback - the callback, must not be null.Multipublic Multi<T> invokeUni(Function<? super org.reactivestreams.Subscription,Uni<?>> action)
Multi invoking the given @{code action} when the subscription event is received.
Unlike invoke(Consumer), the passed function returns a Uni. When the produced Uni sends
the subscription, the function is called. The subscription event is passed downstream only when the Uni
completes. If the produced Uni fails or if the function throws an exception, the failure is propagated
downstream.
action - the callback, must not be nullMultiCopyright © 2019–2020 SmallRye. All rights reserved.