Hi, what is the difference between these two funct...
# compose
s
Hi, what is the difference between these two function definition, in terms of when the backing MutableState changes? fun Demo (coin: State<Int>) vs fun Demo(coin: Int)
a
If these are composable functions, I don’t think there’s any difference but you should use the latter form as the parameter doesn’t necessarily have to be a
State
.
s
@Albert Chang Yes, it is Composable functions, thanks i though latter one won,t recompose when it's data changes.
n
You must definitely choose the second one… This is the definition of _unidirectional data flow_: “State flows down, events flows up” https://developer.android.com/jetpack/compose/state#state-hoisting