[英]Reactor WebFlux: help to understand how to work flatMap()
Please help to understand how can I use fkatMap() in my example:请帮助了解如何在我的示例中使用 fkatMap():
Flux.just("1,2,3", "4,5,6")
.flatMap(// to do something)
.collect(Collectors.toList())
.subscribe(System.out::println);
I read the documentation.我阅读了文档。 I understood how to work flatMap() but I can't understand how I need to use in my example.
我了解如何工作 flatMap() 但我不明白我需要如何在我的示例中使用。 Thanks.
谢谢。
As Kayaman already answered, you can do the following:正如Kayaman已经回答的那样,您可以执行以下操作:
Flux.just("1,2,3", "4,5,6")
.flatMap(i -> Flux.fromIterable(Arrays.asList(i.split(","))))
.collect(Collectors.toList())
.subscribe(System.out::println);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.