将Flowable <List <T >>转换为List <T>

时间:2019-07-30 13:12:50

标签: android kotlin observable

我想将FlowableList转换为List。有什么建议吗?

private val flowableList: Flowable<List<T>>
private val list = listOf<T>(flowableList)

1 个答案:

答案 0 :(得分:2)

只需使用toList方法

val list = flowableList.toList().map { it.flatten() }