Class UniKt
-
- All Implemented Interfaces:
public final class UniKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> TawaitSuspending(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. -
-
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
Tis 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
coroutineContextby 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 ofUni.createFrom().item<T>(() -> T). The behaviour can be changed by passing an own context that's used forasyncexecution of the given suspendSupplier.
-
-
-
-