Landry Norris
02/05/2022, 7:59 PMLandry Norris
02/05/2022, 8:02 PMAdam Powell
02/05/2022, 8:04 PM@Composable fun
must be known to be stable, and their new values must compare .equals
to their old values.Adam Powell
02/05/2022, 8:05 PM.equals
might take a whileLandry Norris
02/05/2022, 8:11 PMAdam Powell
02/05/2022, 8:21 PMAdam Powell
02/05/2022, 8:22 PMLandry Norris
02/05/2022, 8:29 PMColumn {
Text(text1)
Text(text2)
}
in the case of multiple variables, or
Column {
Text(state.text1)
Text(state.text2)
}
in the case of a data class. You could have text1 and text2 as two different state variables, where I know that running text1.value = "foo" only re-renders the first text, or you could have a data class ScreenState(text1, text2). In the second case, if I were to run state.value = state.value.copy(text1 = "foo")
, would this be identical to the first case, causing only the top Text to get re-rendered, or will both get re-rendered due to changing the value of the single state variable?Adam Powell
02/05/2022, 8:35 PMAdam Powell
02/05/2022, 8:38 PMvar text1 by remember { mutableStateOf(...) }
var text2 by remember { mutableStateOf(...) }
// ...
Column {
Text(text1) // call to getValue happens while evaluating parameters to pass
Text(text2) // call to getValue happens while evaluating parameters to pass
}
Adam Powell
02/05/2022, 8:39 PMText
call is what is invalidated in both casesAdam Powell
02/05/2022, 8:40 PMColumn
is inline, the containing recompose scope is the containing scope of Column
Adam Powell
02/05/2022, 8:42 PMText
skipping when the string passed to it is the same as the previous recompositionAdam Powell
02/05/2022, 8:43 PM.value
(or delegate getValue
) occursLandry Norris
02/05/2022, 8:44 PMAdam Powell
02/05/2022, 8:46 PMTexts
gets recomposed. Both calls to Text
happen. The function body skipping behavior added to the Text
function by the compose compiler plugin compares the parameters of skippable composable functions and determines whether to return early without doing work or notLandry Norris
02/05/2022, 8:48 PMAdam Powell
02/05/2022, 8:49 PMAdam Powell
02/05/2022, 8:49 PMLandry Norris
02/05/2022, 8:52 PM