本文整理了Java中reactor.core.publisher.Mono.zipWhen()
方法的一些代码示例,展示了Mono.zipWhen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.zipWhen()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:zipWhen
[英]Wait for the result from this mono, use it to create a second mono via the provided rightGenerator function and combine both results into a Tuple2.
[中]等待此mono的结果,使用它通过提供的rightGenerator函数创建第二个mono,并将两个结果合并为一个Tuple2。
代码示例来源:origin: reactor/reactor-core
/**
* Wait for the result from this mono, use it to create a second mono via the
* provided {@code rightGenerator} function and combine both results into a {@link Tuple2}.
*
* <p>
* <img class="marble" src="doc-files/marbles/zipWhenForMono.svg" alt="">
*
* @param rightGenerator the {@link Function} to generate a {@code Mono} to combine with
* @param <T2> the element type of the other Mono instance
*
* @return a new combined Mono
*/
public final <T2> Mono<Tuple2<T, T2>> zipWhen(Function<T, Mono<? extends T2>> rightGenerator) {
return zipWhen(rightGenerator, Tuples::of);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void testMonoAndFunctionRightSideEmpty() {
StepVerifier.create(
Mono.just("foo").zipWhen(t -> Mono.empty()))
.expectComplete()
.verify();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void testMonoAndFunctionEmpty() {
StepVerifier.create(
Mono.<String>empty().zipWhen(MonoTests::handle))
.expectComplete()
.verify();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void testMonoAndFunction() {
StepVerifier.create(Mono.just("source")
.zipWhen(t -> handle(t)))
.expectNextMatches(pair -> pair.getT1().equals("source") && pair.getT2() == 6)
.expectComplete()
.verify();
}
代码示例来源:origin: io.projectreactor/reactor-core
/**
* Wait for the result from this mono, use it to create a second mono via the
* provided {@code rightGenerator} function and combine both results into a {@link Tuple2}.
*
* <p>
* <img class="marble" src="doc-files/marbles/zipWhenForMono.svg" alt="">
*
* @param rightGenerator the {@link Function} to generate a {@code Mono} to combine with
* @param <T2> the element type of the other Mono instance
*
* @return a new combined Mono
*/
public final <T2> Mono<Tuple2<T, T2>> zipWhen(Function<T, Mono<? extends T2>> rightGenerator) {
return zipWhen(rightGenerator, Tuples::of);
}
代码示例来源:origin: LearningByExample/reactive-ms-example
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress)
.zipWhen(this::sunriseSunset, LocationResponse::new)
.transform(this::serverResponse);
}
内容来源于网络,如有侵权,请联系作者删除!