java - react 器WebFlux : help to understand how to work flatMap()

标签 java spring-webflux project-reactor reactor

请帮助理解如何在我的示例中使用 fkatMap():

Flux.just("1,2,3", "4,5,6")
                .flatMap(// to do something)
                .collect(Collectors.toList())
                .subscribe(System.out::println);

我阅读了文档。我理解如何工作 flatMap() 但我不明白我需要如何在我的示例中使用。 谢谢。

最佳答案

正如 Kayaman 已经回答的那样,您可以执行以下操作:

Flux.just("1,2,3", "4,5,6")
        .flatMap(i -> Flux.fromIterable(Arrays.asList(i.split(","))))
        .collect(Collectors.toList())
        .subscribe(System.out::println);

关于java - react 器WebFlux : help to understand how to work flatMap(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60352410/

相关文章:

Java - 类型不匹配 : cannot convert from ImmutableList<Object> to ImmutableList<String>

spring-webflux - 使用 Spring WebFlux 的 session 和请求范围

java - Spring WebClient获取请求返回 "Connection refused: localhost/"

javascript - 我应该如何更新 *.eslintrc* 到 ESLint 以查看更改?

java - 如何使用 Mono & Flux 限制并发 http 请求

java - 使用 play 框架的查询无需我询问即可返回相关表

JavaFX 应用程序线程到任务通信

spring-security - 更改 Spring Security WebFilter 的顺序

java - 使用 Schedulers.single() 在 Reactor StepVerifier 中重新抛出断言错误

java - 如何仅从java中给定的字母数字单词中获取字母表?