如何从Mono创建Flux [英] How to create Flux from Mono
本文介绍了如何从Mono创建Flux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Mono A.对象A包含两个列表。我想直接创建两个Flux。这可能没有block()吗?
I have a Mono A. The Object A contains two lists. I want to create direct two Flux. Is this possible without block()?
Mono<A> a = ... ;
Flux<AList1> a1 = Flux.fromIterable(a.block().getList1());
推荐答案
使用Mono.flatMapMany()方法:
Use Mono.flatMapMany() method:
Flux flux1 = mono.map(A::getList1).flatMapMany(Flux::fromIterable);
Flux flux2 = mono.map(A::getList2).flatMapMany(Flux::fromIterable);
这篇关于如何从Mono创建Flux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文