(forgive me if there’s a better channel, I wasn’t ...
# compose-desktop
z
(forgive me if there’s a better channel, I wasn’t sure which of the compose channels to raise compiler related discussion in) When updating Jetbrains’ compose-compiler from 1.5.10.2 to 1.5.13.3, I noticed a subtle change that surprised me. The behavior might be correct, but I don’t fully understand why. The snippet I’m testing this is:
Copy code
Column {
  var text2Enabled by rememberRetained { mutableStateOf(true) }
  val text1 by rememberRetained { mutableStateOf("Text") }
  Text(modifier = Modifier.testTag(TAG_RETAINED_1), text = text1)
  Button(
    modifier = Modifier.testTag("TAG_BUTTON"),
    onClick = { text2Enabled = !text2Enabled },
  ) {
    Text("Toggle")
  }
  if (text2Enabled) {
    val text2 by rememberRetained { mutableStateOf("Text") }
    Text(modifier = Modifier.testTag(TAG_RETAINED_2), text = text2)
  }
}
On 1.5.10.2, the first two
rememberRetained
calls have the same
currentCompositeKeyHash
, and the third one (under text2Enabled) is different. On 1.5.13.3, all three of them have the same
currentCompositeKeyHash
. Is that expected?
a
What is
rememberRetained
?
p
Excellent question that occurred to me as well.
z
It’s similar to rememberSaveable and part of the Circuit architecture. The short answer is got elsewhere though is the latter is correct and more or less just a bug fix
Seems it reverted in 1.5.14