本文整理了Java中reactor.core.publisher.Mono.or()
方法的一些代码示例,展示了Mono.or()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.or()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:or
[英]Emit the first available result from this mono or the other mono.
[中]从该单声道或其他单声道发出第一个可用结果。
代码示例来源:origin: reactor/reactor-core
@Test
public void promiseDelays() throws Exception {
Tuple2<Long, String> h = Mono.delay(Duration.ofMillis(3000))
.log("time1")
.map(d -> "Spring wins")
.or(Mono.delay(Duration.ofMillis(2000)).log("time2").map(d -> "Spring Reactive"))
.flatMap(t -> Mono.just(t+ " world"))
.elapsed()
.block();
assertThat("Alternate mono not seen", h.getT2(), is("Spring Reactive world"));
System.out.println(h.getT1());
}
代码示例来源:origin: reactor/reactor-core
@Test
public void pairWiseIterable() {
Mono<Integer> f = Mono.first(Arrays.asList(Mono.just(1), Mono.just(2)))
.or(Mono.just(3));
Assert.assertTrue(f instanceof MonoFirst);
MonoFirst<Integer> s = (MonoFirst<Integer>) f;
Assert.assertTrue(s.array != null);
Assert.assertTrue(s.array.length == 2);
f.subscribeWith(AssertSubscriber.create())
.assertValues(1)
.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void pairWise() {
Mono<Integer> f = Mono.first(Mono.just(1), Mono.just(2))
.or(Mono.just(3));
Assert.assertTrue(f instanceof MonoFirst);
MonoFirst<Integer> s = (MonoFirst<Integer>) f;
Assert.assertTrue(s.array != null);
Assert.assertTrue(s.array.length == 3);
f.subscribeWith(AssertSubscriber.create())
.assertValues(1)
.assertComplete();
}
代码示例来源:origin: com.aol.cyclops/cyclops-reactor
/**
* @param other
* @return
* @see reactor.core.publisher.Mono#or(reactor.core.publisher.Mono)
*/
public final Mono<T> or(Mono<? extends T> other) {
return boxed.or(other);
}
/**
代码示例来源:origin: reactor/reactor-netty
/**
* Return a Mono succeeding when a {@link ChannelOperations} has been terminated
*
* @return a Mono succeeding when a {@link ChannelOperations} has been terminated
*/
@Override
public final Mono<Void> onTerminate() {
if (!isPersistent()) {
return connection.onDispose();
}
return FutureMono.from((Future<Void>)this).or(connection.onDispose());
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* Return a Mono succeeding when a {@link ChannelOperations} has been terminated
*
* @return a Mono succeeding when a {@link ChannelOperations} has been terminated
*/
@Override
public final Mono<Void> onTerminate() {
if (!isPersistent()) {
return connection.onDispose();
}
return FutureMono.from((Future<Void>)this).or(connection.onDispose());
}
内容来源于网络,如有侵权,请联系作者删除!