java - Mono 到 Flux 的 Spring 响应式列表
问题描述
我有一个
list.stream()
.map(element -> func());
其中 func() 返回 Mono。Mono<CustomObject>
将此对象列表转换为Flux<CustomObject>
并从流中返回的最简单方法是什么?
解决方案
List<Mono<CustomObject >> monoList = new ArrayList<>();
monoList(object);
Flux<CustomObject> flux = Flux.concat(monoList);
推荐阅读
- tableau-api - Tableau 自定义 sql 和 Athena 的持续问题
- python - ResourceExhaustedError(参见上文的回溯):分配形状为 [1,256,1024,1021] 的张量时出现 OOM
- google-apps-script - 遍历Google表格中的ID数组时如何检查日历事件是否已被删除?
- python - 如何在不转换为 pd.DataFrame 的情况下计算具有 np.nan 值的矩阵上的 np.cov?
- ldap - 多个activiti ldap配置
- javascript - 从没有 math.max 的嵌套数组中返回最大数
- php - 在 RedbeanPHP 中使用 json 对象数组查询表
- r - RMarkdown:“错误:找不到 html_dependency 的路径:”
- python - 是否可以解决 MATLAB 和 Python 之间的滤波器舍入错误?
- javascript - 当 promise 返回成功或失败时调用函数