Erlan Amanatov
06/01/2021, 1:14 PMcomposable
function
@Composable
fun modified(
object1: A,
object2: B) : Boolean {...}
Where A
is a Data Class, B
is a regular class with MutableState
variables.
I use this function to control the Button
, so it's enabled only if there are any differences between the objects.
Button(
...
enabled = modified(object1, object2)
...
)
How does it work? Any changes to MutableState
variables of object2
trigger the modified
function?Zach Klippenstein (he/him) [MOD]
06/01/2021, 1:17 PMAny changes toYes. When you callvariables ofMutableState
trigger theobject2
function?modified
modified
from a composable, and it reads those state values, the composable tracks those reads and will trigger recomposition of the composable that the read happened in when they change.Erlan Amanatov
06/01/2021, 1:25 PMmodified
function will be called only with new object1
or object2
parameters, not by their propertiesAdam Powell
06/01/2021, 1:44 PMAdam Powell
06/01/2021, 1:44 PM