你好,我的代码是这样的:
fun mapBatch(batch: List<String>): Mono<List<MyClass>> ...
fun myFun(stream: Flux<String>): Flux<MyClass> {
return stream
.bufferTimeout(50, Duration.ofSeconds(60L))
.flatMap{ batch -> mapBatch(batch) }
/// now here I would like to get Flux<MyClass> but have Flux<List<MyClass>>
}
如何获取 Flux<T>
来自 Flux<List<T>>
?
最佳答案
您应该使用 .concatMapIterable
或 .flatMapIterable
。
Flux#flatMapIterable
是一个特殊的运算符,用于将表示为 Iterable 的项目“扁平化”为 T 的 react 流。
关于java - 如何将 Flux<List<T>> 扁平化为 Flux<T>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67972425/