本文整理了Java中reactor.core.publisher.Mono.concatWith()
方法的一些代码示例,展示了Mono.concatWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.concatWith()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:concatWith
[英]Concatenate emissions of this Mono with the provided Publisher(no interleave).
[中]将此单声道的发射与提供的发布器连接(无交错)。
代码示例来源:origin: reactor/reactor-core
@Test
public void longDelaysStartEndEmitEmptyWindows() {
StepVerifier.withVirtualTime(() ->
Mono.just("foo")
.delayElement(Duration.ofMillis(400 + 400 + 300))
.concatWith(Mono.delay(Duration.ofMillis(100 + 400 + 100)).then(Mono.empty()))
.windowTimeout(1000, Duration.ofMillis(400))
.concatMap(Flux::collectList)
)
.thenAwait(Duration.ofHours(1))
.assertNext(l -> assertThat(l).isEmpty())
.assertNext(l -> assertThat(l).isEmpty())
.assertNext(l -> assertThat(l).containsExactly("foo"))
.assertNext(l -> assertThat(l).isEmpty())
.assertNext(l -> assertThat(l).isEmpty()) //closing window
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void pairWise2() {
Flux<String> f = Mono.just("test")
.concatWith(Flux.just("test2"));
Assert.assertTrue(f instanceof FluxConcatArray);
FluxConcatArray<String> s = (FluxConcatArray<String>) f;
Assert.assertTrue(s.array != null);
Assert.assertTrue(s.array.length == 2);
StepVerifier.create(f)
.expectNext("test", "test2")
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
@Ignore("use virtual time?")
public void neverEnding() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux<Integer> dematerialize = Mono.just(Signal.next(1))
.concatWith(Mono.never())
.dematerialize();
dematerialize.subscribe(ts);
ts.assertValues(1)
.assertNoError()
.assertComplete();
}
}
代码示例来源:origin: com.aol.cyclops/cyclops-reactor
/**
* @param other
* @return
* @see reactor.core.publisher.Mono#concatWith(org.reactivestreams.Publisher)
*/
public final Flux<T> concatWith(Publisher<? extends T> other) {
return boxed.concatWith(other);
}
/**
代码示例来源:origin: apache/james-project
public Mono<Void> allListenerFuture() {
return synchronousListenerFuture
.concatWith(asynchronousListenerFuture)
.then();
}
代码示例来源:origin: ryanjbaxter/beginners-guide-to-spring-cloud
@Bean
public RouterFunction<ServerResponse> monoRouterFunction(NameHandler nameHandler, GreetingHandler greetingHandler) {
return route(GET("/"), serverRequest -> ServerResponse.ok().contentType(MediaType.TEXT_HTML).body(
greetingHandler.getGreetingStringMono(serverRequest.headers().asHttpHeaders().
getAcceptLanguageAsLocales().get(0).toLanguageTag()).concatWith(Mono.just(" ")).
concatWith(nameHandler.getNameStringMono()), String.class));
}
代码示例来源:origin: pivotalsoftware/ESarch
@GetMapping("/subscribe/order-book/{orderBookId}")
public Flux<ServerSentEvent<OrderBookView>> subscribeToOrderBook(@PathVariable String orderBookId) {
SubscriptionQueryResult<OrderBookView, OrderBookView> subscription = queryGateway
.subscriptionQuery(new OrderBookByIdQuery(new OrderBookId(orderBookId)),
ResponseTypes.instanceOf(OrderBookView.class),
ResponseTypes.instanceOf(OrderBookView.class));
return subscription.initialResult().concatWith(subscription.updates())
.map(ob -> ServerSentEvent.builder(ob).build());
}
代码示例来源:origin: io.projectreactor/reactor-netty
.concatWith(connectSignal).as(MonoSource::wrap);
})
.retry(bridge)
代码示例来源:origin: akarnokd/akarnokd-misc
public static <T> Flux<List<T>> delayedBufferAfterFirst(Flux<T> source, Duration d) {
return source
.publish(f -> {
return f.take(1).collectList()
.concatWith(f.buffer(d).take(1))
.repeatWhen(r -> r.takeUntilOther(f.ignoreElements()));
});
}
}
内容来源于网络,如有侵权,请联系作者删除!