在一个android项目中,我有这样的语句:
import io.reactivex.Completable
import io.reactivex.Single
val itemsList: Single<List<T>> = getItems()
我需要从 itemsList 中获取第一项。
我该怎么做?
最佳答案
作为您的 Single
类型为 List<Item>
, 什么时候你会在你的 apiRepositoryObject
上获取它- 您的网络层对象,您将获得单个 List<Item>
或异常
apiRepositoryObject.getItems()
.subscribe(listOfItems -> {
// The list of item should be handled here
},Throwable::printStackTrace);
关于android - 无法从 Single<List<T>> 获取第一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59323683/