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

x33g5p2x  于2022-01-19 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(238)

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

Flux.sampleFirst介绍

[英]Repeatedly take a value from this Flux then skip the values that follow within a given duration.
[中]重复从该流量中获取一个值,然后跳过给定持续时间内的后续值。

代码示例

代码示例来源:origin: reactor/reactor-core

/**
 * Repeatedly take a value from this {@link Flux} then skip the values that follow
 * within a given duration.
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/sampleFirstAtRegularInterval.svg" alt="">
 *
 * @reactor.discard This operator discards elements that are not part of the sampling.
 *
 * @param timespan the duration during which to skip values after each sample
 *
 * @return a {@link Flux} sampled to the first item of each duration-based window
 */
public final Flux<T> sampleFirst(Duration timespan) {
  return sampleFirst(t -> Mono.delay(timespan));
}

代码示例来源:origin: reactor/reactor-core

Flux<Integer> scenario_sampleFirstTime(){
  return Flux.range(1, 10)
    .delayElements(Duration.ofMillis(200))
    .sampleFirst(Duration.ofSeconds(1));
}

代码示例来源:origin: com.aol.cyclops/cyclops-reactor

/**
 * @param samplerFactory
 * @return
 * @see reactor.core.publisher.Flux#sampleFirst(java.util.function.Function)
 */
public final <U> Flux<T> sampleFirst(Function<? super T, ? extends Publisher<U>> samplerFactory) {
  return boxed.sampleFirst(samplerFactory);
}
/**

代码示例来源:origin: com.aol.cyclops/cyclops-reactor

/**
 * @param timespan
 * @return
 * @see reactor.core.publisher.Flux#sampleFirst(java.time.Duration)
 */
public final Flux<T> sampleFirst(Duration timespan) {
  return boxed.sampleFirst(timespan);
}
/**

代码示例来源:origin: io.projectreactor/reactor-core

/**
 * Repeatedly take a value from this {@link Flux} then skip the values that follow
 * within a given duration.
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/sampleFirstAtRegularInterval.svg" alt="">
 *
 * @reactor.discard This operator discards elements that are not part of the sampling.
 *
 * @param timespan the duration during which to skip values after each sample
 *
 * @return a {@link Flux} sampled to the first item of each duration-based window
 */
public final Flux<T> sampleFirst(Duration timespan) {
  return sampleFirst(t -> Mono.delay(timespan));
}

相关文章

Flux类方法