In my viemodel I get from my RoomDB a list of SmthObjects as StateFlow<List<SmthObject>>.
In my composable I use that list:
val listVM = viewmodel<MyViewModel>()
//var 1
val listVM = listVM.smthObjects.collectAsState()
val list = remember{
**listVM**
}
and next I use this list in LazyColumn
but I cant do :
//var 2
val list = remember{
**mutableStateOf(listVM.smthObjects)**
}
and use list as list.value.collectAsState().value
What is the correct way?
Sometimes doing Google's Codelabs is worth the time it takes.
Use
by(delegate) and you don't have to call.valueIn your case something like this:
Also, you don't want to hoist the state of the directly in the composable but in the view model itself.