reactor.core.publisher.Mono.zipWhen()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(633)

本文整理了Java中reactor.core.publisher.Mono.zipWhen()方法的一些代码示例,展示了Mono.zipWhen()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.zipWhen()方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:zipWhen

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);
}

相关文章

微信公众号

最新文章

更多

Mono类方法