【发布时间】:2021-02-01 03:21:05
【问题描述】:
我想将房间 liveData 委托为 mutableStateOf 的默认值。
// state -- can work with compose such as add or remove
var items: List<Item> by mutableStateOf(listOf())
private set
// room -- persist store the data
val items: LiveData<List<Item>> = itemDao.getAll()
// state(room)? -- get the persistence data and work with compose
val items: List<Item> by mutableStateOf(itemRepository.items.value) // not work
【问题讨论】:
标签: android kotlin android-room android-livedata android-jetpack-compose