project-reactor - 完成第一个 Mono 后执行 Mono 列表
问题描述
完成 1 个单声道后执行单声道列表。
Mono<Project> mono1 = ...;
List<Mono<?>> publishers = new ArrayList<>();
publishers.add(mono2);
publishers.add(mono3);
publishers.add(mono4);
if ( publishers.size() > 0 )
Mono.zip(publishers, res->prj.id);
在这里,我想在完成 Mono1 后执行 Mono 列表。
我可以做连锁。但是,与 Mono.zip 有什么关系...?
解决方案
mono1.then(Mono.zip(publishers, res->prj.id));
查看它的 JavaDocs:
/**
* Let this {@link Mono} complete then play another Mono.
* <p>
* In other words ignore element from this {@link Mono} and transform its completion signal into the
* emission and completion signal of a provided {@code Mono<V>}. Error signal is
* replayed in the resulting {@code Mono<V>}.
*
* <p>
* <img class="marble" src="doc-files/marbles/thenWithMonoForMono.svg" alt="">
*
* <p><strong>Discard Support:</strong> This operator discards the element from the source.
*
* @param other a {@link Mono} to emit from after termination
* @param <V> the element type of the supplied Mono
*
* @return a new {@link Mono} that emits from the supplied {@link Mono}
*/
public final <V> Mono<V> then(Mono<V> other) {
推荐阅读
- python - 如何更改 LSTM 模型中的预测范围?
- javascript - 如何在反应原生中解析“
- symfony - Symfony EasyAdmin 3 在父详细信息页面中显示关系表
- c - fork execlp 和数组参数有问题
- algorithm - 用于检测二维阵列中的多个区域的算法
- mysql - MySQL 位数据类型显示为 0x00。为什么?
- java - 找到大于 X 的最小子数组的方法返回错误的数字
- azure - 无法将 VMSS 组合部署到 ARM 部署
- python - 使用 Celey+RabbitMQ+Redis 实现订单管理服务
- clearscript - ClearScript 的 DotNetFiddle 或类似产品