Colton Idle
01/21/2022, 7:23 AMclass ScreenViewState {
val list = mutableStateListOf<Item>()
and my Item
class ConcreteType(override val type: String = "") : Item {
var something by mutableStateOf("beep")
then in my VM I call
(myItem as ConcreteType).something = "boop"
My composable always beeps, but never boops.KamilH
01/21/2022, 7:32 AMvar
, you doesn’t actually mutate the list. Make your `ConcreteType`’s property not mutable and when you want your composable to recompose, replace
the value on the list.
I think having MutableList
of mutableStateOf
can be called “2 degrees of mutability” that has been described by Zach in mentioned blog postColton Idle
01/21/2022, 7:44 AMKamilH
01/21/2022, 7:52 AMvm.state.people.forEach {
TextButton(onClick = {
it.selected = true
})
so for each people
you put TextButton
, do you do the same in current example? Or maybe you put your items in the LazyColumn
for example?Colton Idle
01/21/2022, 8:01 AMval list = mutableListOf<Item>()
and so that only leaves me with mutableState inside of the ConcreteType and it still does not work.var list = listOf<Item>()
and it still Beeps. No boops.KamilH
01/21/2022, 9:12 AMZach Klippenstein (he/him) [MOD]
01/21/2022, 4:34 PM