bnvinay92
10/07/2023, 12:28 PMParentComposable {
ChildComposable {
remember("constant") { someConstructor() }
}
}
My assumption is that someConstructor
will only get called once but it seems whenever the ParentComposable recomposes the constructor gets called again. Is this how compose works or am i missing something else that's causing the remember to run again?vide
10/07/2023, 12:56 PMascii
10/07/2023, 2:37 PMAdib Faramarzi
10/07/2023, 3:02 PMsomeConstructor
will not get called. But if it goes away from composition and is brought back, it will be called again.bnvinay92
10/07/2023, 4:43 PMParentComposable {
when {
case 1 -> ChildComposable
case 2 -> ChildComposable
}
}
It looks like the compose compiler generates different uids for each one so my case statements were removing and adding these from the composition instead of recomposing it.Zach Klippenstein (he/him) [MOD]
10/08/2023, 2:30 AMascii
10/08/2023, 3:44 AMkey()
could be useful; if it's the same composable fn and you don't want one to be removed and the other added.Adib Faramarzi
10/08/2023, 6:49 AMfor
code in the Android docs for Compose (in which they use a key(item.id)
in the for
block to know which item is which.