叛变 - 项目反应堆的单声道()fromcallable()是什么

发布于 2025-02-07 17:12:26 字数 108 浏览 3 评论 0原文

我是叛变的新手,但对项目反应堆很熟悉。

我正在寻找与Mutiny中的mono.fromcallable()的对应物,以从可呼叫或匿名lambda创建一个uni?

I am new to Mutiny but have familiarity with Project Reactor.

I am looking for the counterpart to Mono.fromCallable() in Mutiny to create a Uni from a Callable or anonymous lambda?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪化雨蝶 2025-02-14 17:12:26

从lambda创建一个UNI

Uni.createFrom().item(() -> "Testing Uni");

您可以使用以下

Uni.createFrom().future( new FutureTask<>( callable ));

方式 /创建unis“ rel =” nofollow noreferrer“>创建一个uni :

Uni.createFrom().item(1); // Emit 1 at subscription time
Uni.createFrom().item(() -> x); // Emit x at subscription time, the supplier is invoked for each subscription
Uni.createFrom().completionStage(cs); // Emit the item from this completion stage
Uni.createFrom().completionStage(() -> cs); // Emit the item from this completion stage, the stage is not created before subscription
Uni.createFrom().failure(exception); // Emit the failure at subscription time
Uni.createFrom().deferred(() -> Uni.from().value(x)); // Defer the uni creation until subscription. Each subscription can produce a different uni
Uni.createFrom().nullItem(); // Emit null at subscription time
Uni.createFrom().voidItem(); // Create a Uni not emitting any signal (returns Uni<Void>()
Uni.createFrom().nothing(); // Create a Uni not emitting any signal
Uni.createFrom().publisher(publisher); // Create a Uni from a Reactive Streams Publisher

You can create a Uni from a lambda using:

Uni.createFrom().item(() -> "Testing Uni");

For java.util.concurrent.Callable:

Uni.createFrom().future( new FutureTask<>( callable ));

Other ways you can create a Uni:

Uni.createFrom().item(1); // Emit 1 at subscription time
Uni.createFrom().item(() -> x); // Emit x at subscription time, the supplier is invoked for each subscription
Uni.createFrom().completionStage(cs); // Emit the item from this completion stage
Uni.createFrom().completionStage(() -> cs); // Emit the item from this completion stage, the stage is not created before subscription
Uni.createFrom().failure(exception); // Emit the failure at subscription time
Uni.createFrom().deferred(() -> Uni.from().value(x)); // Defer the uni creation until subscription. Each subscription can produce a different uni
Uni.createFrom().nullItem(); // Emit null at subscription time
Uni.createFrom().voidItem(); // Create a Uni not emitting any signal (returns Uni<Void>()
Uni.createFrom().nothing(); // Create a Uni not emitting any signal
Uni.createFrom().publisher(publisher); // Create a Uni from a Reactive Streams Publisher
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文