【发布时间】:2021-07-03 05:36:36
【问题描述】:
在 ViewModel 中:
val drillerCatList: List<Int> = emptyList()
val shownCategoriesFlow = wordDao.getShownCategories() // which returns type Flow<List<CategoryItem>>
分类对象:
data class CategoryItem(
val categoryName: String,
val categoryNumber: Int,
val categoryShown: Boolean = false,
@PrimaryKey(autoGenerate = true) var id: Int = 0
) : Parcelable {
}
如何从 shownCategoriesFlow: FLow 中检索所有 categoryNumber 值并在 ViewModel 中使用这些值填充 DrillerCatList: List?
【问题讨论】:
标签: android kotlin kotlin-coroutines android-viewmodel android-mvvm