本文整理了Java中reactor.core.publisher.Flux.scanWith()
方法的一些代码示例,展示了Flux.scanWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flux.scanWith()
方法的具体详情如下:
包路径:reactor.core.publisher.Flux
类名称:Flux
方法名:scanWith
[英]Reduce this Flux values with the help of an accumulator BiFunctionand also emits the intermediate results. A seed value is lazily provided by a Supplier invoked for each Subscriber.
The accumulation works as follows:
result[0] = initialValue;
result[1] = accumulator(result[0], source[0])
result[2] = accumulator(result[1], source[1])
result[3] = accumulator(result[2], source[2])
...
[中]在蓄能器双功能的帮助下降低该通量值,并发出中间结果。种子值由为每个订阅服务器调用的供应商延迟提供。
累积工作如下:
result[0] = initialValue;
result[1] = accumulator(result[0], source[0])
result[2] = accumulator(result[1], source[1])
result[3] = accumulator(result[2], source[2])
...
代码示例来源:origin: reactor/reactor-core
/**
* Reduce this {@link Flux} values with an accumulator {@link BiFunction} and
* also emit the intermediate results of this function.
* <p>
* The accumulation works as follows:
* <pre><code>
* result[0] = initialValue;
* result[1] = accumulator(result[0], source[0])
* result[2] = accumulator(result[1], source[1])
* result[3] = accumulator(result[2], source[2])
* ...
* </code></pre>
*
* <p>
* <img class="marble" src="doc-files/marbles/scan.svg" alt="">
*
* @param initial the initial leftmost argument to pass to the reduce function
* @param accumulator the accumulating {@link BiFunction}
* @param <A> the accumulated type
*
* @return an accumulating {@link Flux} starting with initial state
*
*/
public final <A> Flux<A> scan(A initial, BiFunction<A, ? super T, A> accumulator) {
Objects.requireNonNull(initial, "seed");
return scanWith(() -> initial, accumulator);
}
代码示例来源:origin: reactor/reactor-core
@Override
protected List<Scenario<String, String>> scenarios_operatorError() {
return Arrays.asList(
scenario(f -> f.scan(item(0), (a, b) -> {
throw exception();
})).receiveValues(item(0)),
scenario(f -> f.scan(item(0), (a, b) -> null))
.receiveValues(item(0)),
scenario(f -> f.scanWith(() -> null, (a, b) -> b)),
scenario(f -> f.scanWith(() -> {
throw exception();
},
(a, b) -> b))
);
}
代码示例来源:origin: com.aol.cyclops/cyclops-reactor
/**
* @param initial
* @param accumulator
* @return
* @see reactor.core.publisher.Flux#scanWith(java.util.function.Supplier, java.util.function.BiFunction)
*/
public final <A> Flux<A> scanWith(Supplier<A> initial, BiFunction<A, ? super T, A> accumulator) {
return boxed.scanWith(initial, accumulator);
}
/**
代码示例来源:origin: io.projectreactor/reactor-core
/**
* Reduce this {@link Flux} values with an accumulator {@link BiFunction} and
* also emit the intermediate results of this function.
* <p>
* The accumulation works as follows:
* <pre><code>
* result[0] = initialValue;
* result[1] = accumulator(result[0], source[0])
* result[2] = accumulator(result[1], source[1])
* result[3] = accumulator(result[2], source[2])
* ...
* </code></pre>
*
* <p>
* <img class="marble" src="doc-files/marbles/scan.svg" alt="">
*
* @param initial the initial leftmost argument to pass to the reduce function
* @param accumulator the accumulating {@link BiFunction}
* @param <A> the accumulated type
*
* @return an accumulating {@link Flux} starting with initial state
*
*/
public final <A> Flux<A> scan(A initial, BiFunction<A, ? super T, A> accumulator) {
Objects.requireNonNull(initial, "seed");
return scanWith(() -> initial, accumulator);
}
内容来源于网络,如有侵权,请联系作者删除!