从Flux转换到Mono(Convert from Flux to Mono)
如何将1个元素的Flux转换为Mono?
Flux.fromArray(arrayOf(1,2,1,1,1,2))
.distinct()
.take(1)
我如何使这个单声道(1)?
How can I convert from a Flux with 1 element to a Mono?
Flux.fromArray(arrayOf(1,2,1,1,1,2))
.distinct()
.take(1)
How do I make this a Mono(1)?
原文:https://stackoverflow.com/questions/42021559
更新时间:2020-02-03 19:52
最满意答案
取而代之的是take(1) ,你可以使用next() 。
这将通过获取第一个发射项目将Flux转换为值Mono ,如果Flux本身为空,则将其转换为空Mono。
Instead of take(1), you could use next().
This will transform the Flux into a valued Mono by taking the first emitted item, or an empty Mono if the Flux is empty itself.
2017-02-03
相关问答
我认为Flux.combineLatest静态方法可以帮助你:因为你的Mono只发出1个元素,那个元素将永远是与Flux每个输入值相结合的元素。 Flux.combineLatest(arr ->