问题描述
完成 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) {