Klaas Kabini
02/20/2020, 7:12 PM@ModelLabelState@Model
data class LabelState(var count:Int)LabelStateremember@Composable
fun LabelThatPassStateAsParameter(labelState: LabelState){
    Text(text = "$labelState.count",
         style = MaterialTheme.typography().body1)
}state@Modelrememberval labelState = state {0}val labelState = remember { mutableStateOf(0) }@Composable
fun LabelWithStateComposableThatDoesReferentialEquality(){
   val labelState = state {0}    
   Text(text = "$labelState.count", 
        style = MaterialTheme.typography().body1)
}labelState2 = remember { LabelState(0) }val labelState2 = remember { mutableStateOf(value = 0, areEquivalent = StructurallyEqual) }Leland Richardson [G]
02/20/2020, 7:38 PMIn case where a composable function is called with the same inputs multiple times, compose runtime will check against the Slot table whether the same inputs have corresponding outputs that were previously cached. If yes, then the compose runtime will retrieve the previously cached results otherwise insert new inputs and their corresponding results to the Slot Table.This is more or less correct, but there are some nuances. We call this “skipping” in that we will “skip” the execution of a composable function if certain criteria is met where we think it is safe to do so. That criteria is something we are constantly evaluating and may shift over time as our compiler gets smarter or we change implementations. Right now, one big limitation here is that we are only skipping when all of the parameters you passed into the composable function are either @Model, @Immutable, or a “primitive” type. We may relax this constraint in the future, but we would rather start in a conservative place since “false positives” here can significantly reduce users trust in the system. Another side effect of this is that currently lambda literals are almost guaranteed to break the “skippability” of a composable, however we are working on a very significant optimization that will allow us to treat lambdas differently.
Given that understanding, it means that theI’m not sure what you mean by this, but let’s use an example… If i write the code:passed as input parameter to a composable in the following code snippet will be positionally memoized despite that is is not wrapped insideLabelStatecomposable.remember
LabelThatPassStateAsParameter(LabelState(0))LabelThatPassStateAsParameterpula
02/20/2020, 7:48 PMLeland Richardson [G]
02/20/2020, 8:11 PMLeland Richardson [G]
02/20/2020, 8:13 PMequalsLeland Richardson [G]
02/20/2020, 8:13 PMLeland Richardson [G]
02/20/2020, 8:14 PMLeland Richardson [G]
02/20/2020, 8:14 PMvarKlaas Kabini
02/21/2020, 6:08 AMKlaas Kabini
02/21/2020, 6:16 AMLeland Richardson [G]
02/21/2020, 6:50 AM