public class UniHelper extends Object
| Constructor and Description |
|---|
UniHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <T> io.smallrye.mutiny.subscription.UniSubscriber<T> |
toSubscriber(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
Adapts an Vert.x
Handler<AsyncResult<T>> to an UniSubscriber. |
static <T> io.smallrye.mutiny.Uni<T> |
toUni(Consumer<io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>> handler)
Returns a
Uni that, when subscribed, uses the provided handler to adapt a callback-based
asynchronous method. |
public static <T> io.smallrye.mutiny.Uni<T> toUni(Consumer<io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>> handler)
Uni that, when subscribed, uses the provided handler to adapt a callback-based
asynchronous method.
For example:
{
@code
io.vertx.core.Vertx vertx = Vertx.vertx();
Uni blockingMethodResult = UniHelper
.toMaybe(handler -> vertx. executeBlocking(fut -> fut.complete(invokeBlocking()), handler));
}
This is useful when using Mutiny without the Vert.x Mutiny API or your own asynchronous methods.
handler - the code executed when the returned Uni is subscribed.public static <T> io.smallrye.mutiny.subscription.UniSubscriber<T> toSubscriber(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
Handler<AsyncResult<T>> to an UniSubscriber.
The returned observer can be subscribed to an Uni.subscribe().
handler - the handler to adaptCopyright © 2019–2020 SmallRye. All rights reserved.