Class UniKt

  • All Implemented Interfaces:

    
    public final class UniKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final static <T extends Any> T awaitSuspending(Uni<T> $self) Awaits the result of this Uni while suspending the surrounding coroutine.
      final static <T extends Any> Uni<T> asUni(Deferred<T> $self) Provide this Deferreds value or failure as Uni.
      final static <T extends Any> Uni<T> uni(CoroutineScope context, SuspendFunction0<T> suspendSupplier) Produce a Uni from given suspendSupplier in a non-suspending context.
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • awaitSuspending

         final static <T extends Any> T awaitSuspending(Uni<T> $self)

        Awaits the result of this Uni while suspending the surrounding coroutine.

        As soon as this Uni succeeds with an item, that item will be returned. Be aware of, that since the type parameter T is determined from the underlying Java type system, there is no first-class type safety and the resulting item may be null.

        If this Uni results in a failure that failure is thrown.

        A cancellation of the coroutine context will cancel the subscription to this Uni and no event will be emitted anymore.

      • asUni

        @ExperimentalCoroutinesApi() final static <T extends Any> Uni<T> asUni(Deferred<T> $self)

        Provide this Deferreds value or failure as Uni.

        If the surrounding coroutine fails or gets cancelled that failure is propagated as well.

      • uni

        @ExperimentalCoroutinesApi() final static <T extends Any> Uni<T> uni(CoroutineScope context, SuspendFunction0<T> suspendSupplier)

        Produce a Uni from given suspendSupplier in a non-suspending context.

        The suspendSupplier block isn't attached to the structured concurrency of the current coroutineContext by default but executed in the GlobalScope, that means that failures raised from suspendSupplier will not be thrown immediately but propagated to the resulting Uni, similar to the behavior of Uni.createFrom().item<T>(() -> T). The behaviour can be changed by passing an own context that's used for async execution of the given suspendSupplier.