Archie
07/26/2020, 2:58 PM@Composable
fun Greetings() {
val state = state { "Hello" }
Column {
Text(text = state.value)
Button(onClick = {
state.value = "Hello"
}) {
Text(text = "Greet!")
}
}
}
Notice that the initial value of state is "Hello" and whenever the Button is clicked, it sets the value of the state to the same value (state.value = "Hello"
). Does this trigger recomposition? or recomposition is only triggered when state
is set with a different value? Also is there a hook or callback I could attach to see how recomposition works in compose
?Adam Powell
07/26/2020, 3:02 PMAdam Powell
07/26/2020, 3:02 PM.equals
Adam Powell
07/26/2020, 3:03 PMArchie
07/26/2020, 3:16 PMIt depends on the policy you set on the state object...I see so thats whats it for..
As for a hook or callback, which part are you looking for?hmmm... now im interested in both...
Adam Powell
07/26/2020, 3:23 PMAdam Powell
07/26/2020, 3:23 PMAdam Powell
07/26/2020, 3:24 PMAdam Powell
07/26/2020, 3:26 PMAdam Powell
07/26/2020, 3:27 PMAdam Powell
07/26/2020, 3:28 PMAdam Powell
07/26/2020, 3:28 PMArchie
07/26/2020, 3:35 PMArchie
07/26/2020, 3:57 PMreferentialEqualityPolicy
and not structuralEqualityPolicy
?romainguy
07/26/2020, 4:42 PMAdam Powell
07/26/2020, 4:51 PMAdam Powell
07/26/2020, 4:53 PMAdam Powell
07/26/2020, 4:54 PMArchie
07/26/2020, 5:01 PMromainguy
07/26/2020, 5:22 PMArchie
07/26/2020, 5:28 PMit should never affect correctness of the resulting composition since state changes are always idempotentare you pertaining to my example or is it something else?
Archie
07/26/2020, 5:31 PMstate
is an object rather than it just being a string.Adam Powell
07/26/2020, 5:36 PMArchie
07/26/2020, 5:37 PM