对 Single<List<T>> 中的每个项目应用转换

Applying transformation to every item in Single<List<T>>

我有一个val singleList: Single<List<EntityItem>> = ...

我还有一个自定义转换器可以将 ItemEntity 转换为 Item (做 transformer::fromEntitytransformer.fromEntity(entity)

我如何使用 RxJava 运算符对 singleList 中的每个 EntityItem 进行 运行 这种转换,以便 Single<List<EntityItem>> 变为 Single<List<Item>>

您可以使用 .map { ... } on Single<T> to transform the value it holds, and inside map the items of the list:

val result = singleList.map { it.map(transformer::fromEntity) }