https://kotlinlang.org logo
#compose
Title
# compose
s

Shakil Karim

06/20/2021, 12:28 PM
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

Albert Chang

06/20/2021, 1:18 PM
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

Shakil Karim

06/20/2021, 2:36 PM
@Albert Chang Yes, it is Composable functions, thanks i though latter one won,t recompose when it's data changes.
n

nglauber

06/21/2021, 2:47 AM
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