Class UniOnSubscribe<T>

  • Type Parameters:
    T - the type of item

    public class UniOnSubscribe<T>
    extends java.lang.Object
    Group to configure the action to execute when the observed 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 
      Constructor Description
      UniOnSubscribe​(Uni<T> upstream)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Uni<T> call​(java.util.function.Function<? super UniSubscription,​Uni<?>> action)
      Produces a new Uni invoking the given @{code action} when the subscription event is received.
      Uni<T> call​(java.util.function.Supplier<Uni<?>> action)
      Produces a new Uni invoking the given @{code action} when the subscription event is received.
      Uni<T> invoke​(java.lang.Runnable callback)
      Produces a new Uni invoking the given callback when the subscription is received.
      Uni<T> invoke​(java.util.function.Consumer<? super UniSubscription> callback)
      Produces a new Uni invoking the given callback when the subscription is received.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UniOnSubscribe

        public UniOnSubscribe​(Uni<T> upstream)
    • Method Detail

      • invoke

        @CheckReturnValue
        public Uni<T> invoke​(java.util.function.Consumer<? super UniSubscription> callback)
        Produces a new Uni 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.

        Parameters:
        callback - the callback, must not be null.
        Returns:
        the new Uni
      • invoke

        @CheckReturnValue
        public Uni<T> invoke​(java.lang.Runnable callback)
        Produces a new Uni 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.

        Parameters:
        callback - the callback, must not be null.
        Returns:
        the new Uni
      • call

        @CheckReturnValue
        public Uni<T> call​(java.util.function.Function<? super UniSubscription,​Uni<?>> action)
        Produces a new Uni 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.

        Parameters:
        action - the callback, must not be null
        Returns:
        the new Uni
      • call

        @CheckReturnValue
        public Uni<T> call​(java.util.function.Supplier<Uni<?>> action)
        Produces a new Uni 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.

        Parameters:
        action - the callback, must not be null
        Returns:
        the new Uni