本文整理了Java中reactor.core.publisher.Mono.ignoreElement()
方法的一些代码示例,展示了Mono.ignoreElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.ignoreElement()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:ignoreElement
[英]Ignores onNext signal (dropping it) and only propagates termination events.
[中]忽略onNext信号(丢弃它),只传播终止事件。
代码示例来源:origin: reactor/reactor-core
/**
* Let this {@link Mono} complete then play another {@link Publisher}.
* <p>
* In other words ignore element from this mono and transform the completion signal into a
* {@code Flux<V>} that will emit elements from the provided {@link Publisher}.
*
* <p>
* <img class="marble" src="doc-files/marbles/thenManyForMono.svg" alt="">
*
* @reactor.discard This operator discards the element from the source.
*
* @param other a {@link Publisher} to emit from after termination
* @param <V> the element type of the supplied Publisher
*
* @return a new {@link Flux} that emits from the supplied {@link Publisher} after
* this Mono completes.
*/
public final <V> Flux<V> thenMany(Publisher<V> other) {
@SuppressWarnings("unchecked")
Flux<V> concat = (Flux<V>)Flux.concat(ignoreElement(), other);
return Flux.onAssembly(concat);
}
代码示例来源:origin: reactor/reactor-core
@Test(timeout = 5000)
public void allEmptyIterable() {
Assert.assertNull(Mono.first(Arrays.asList(Mono.empty(),
Mono.delay(Duration.ofMillis(250))
.ignoreElement()))
.block());
}
代码示例来源:origin: reactor/reactor-core
@Test(timeout = 5000)
public void allEmpty() {
Assert.assertNull(Mono.first(Mono.empty(),
Mono.delay(Duration.ofMillis(250))
.ignoreElement())
.block());
}
代码示例来源:origin: reactor/reactor-core
@Test
public void apiTakeCompleteBeforeDuration() {
StepVerifier.withVirtualTime(() ->
Mono.delay(Duration.ofMillis(100))
.ignoreElement()
.take(Duration.ofMillis(200))
)
.thenAwait(Duration.ofMillis(200))
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void longEmptyEmitsEmptyWindowsRegularly() {
StepVerifier.withVirtualTime(() -> Mono.delay(Duration.ofMillis(350))
.ignoreElement()
.as(Flux::from)
.windowTimeout(1000, Duration.ofMillis(100))
.concatMap(Flux::collectList)
)
.thenAwait(Duration.ofMinutes(1))
.assertNext(l -> assertThat(l).isEmpty())
.assertNext(l -> assertThat(l).isEmpty())
.assertNext(l -> assertThat(l).isEmpty())
.assertNext(l -> assertThat(l).isEmpty())
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void sampleIncludesLastItem() {
Flux<Integer> source = Flux.concat(
Flux.range(1, 5),
Mono.delay(Duration.ofMillis(300)).ignoreElement().map(Long::intValue),
Flux.just(80, 90, 100)
).hide();
Duration duration = StepVerifier.create(source.sample(Duration.ofMillis(250)))
.expectNext(5)
.expectNext(100)
.verifyComplete();
//sanity check on the sequence duration
assertThat(duration.toMillis()).isLessThan(500);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void apiTakeUntilOtherCompleteBeforeOther() {
TestPublisher<String> other = TestPublisher.create();
StepVerifier.withVirtualTime(() ->
Mono.delay(Duration.ofMillis(100))
.ignoreElement()
.takeUntilOther(other)
)
.thenAwait(Duration.ofMillis(200))
.then(() -> other.next("go"))
.verifyComplete();
other.assertCancelled();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void sampleIncludesLastItem() {
StepVerifier.withVirtualTime(() ->
Flux.concat(
Flux.range(1, 5),
Mono.delay(Duration.ofMillis(260)).ignoreElement().map(Long::intValue),
Flux.just(80, 90, 100)
).hide()
.sampleTimeout(i -> Mono.delay(Duration.ofMillis(250))))
.thenAwait(Duration.ofMillis(500))
.expectNext(5)
.expectNext(100)
.verifyComplete();
}
代码示例来源:origin: com.aol.cyclops/cyclops-reactor
/**
* @return
* @see reactor.core.publisher.Mono#ignoreElement()
*/
public final Mono<T> ignoreElement() {
return boxed.ignoreElement();
}
/**
代码示例来源:origin: io.projectreactor/reactor-core
/**
* Let this {@link Mono} complete then play another {@link Publisher}.
* <p>
* In other words ignore element from this mono and transform the completion signal into a
* {@code Flux<V>} that will emit elements from the provided {@link Publisher}.
*
* <p>
* <img class="marble" src="doc-files/marbles/thenManyForMono.svg" alt="">
*
* @reactor.discard This operator discards the element from the source.
*
* @param other a {@link Publisher} to emit from after termination
* @param <V> the element type of the supplied Publisher
*
* @return a new {@link Flux} that emits from the supplied {@link Publisher} after
* this Mono completes.
*/
public final <V> Flux<V> thenMany(Publisher<V> other) {
@SuppressWarnings("unchecked")
Flux<V> concat = (Flux<V>)Flux.concat(ignoreElement(), other);
return Flux.onAssembly(concat);
}
代码示例来源:origin: io.reactivesocket/reactivesocket-core
private Mono<Void> handleFireAndForget(int streamId, Mono<Void> result) {
return result
.doOnSubscribe(subscription -> addSubscription(streamId, subscription))
.doOnError(errorConsumer)
.doFinally(signalType -> removeSubscription(streamId))
.ignoreElement();
}
内容来源于网络,如有侵权,请联系作者删除!