Jonathan
05/12/2025, 1:30 PMderivedStateOf
? Is it safe and or efficient to “nest” calls ie call another derivedStateOf
property inside the calculation
block? Is there a diminishing returns on nesting? Will there be recomposition delays by heavily nesting?Jonathan
05/12/2025, 1:31 PMval opp by derivedStateOf { distance(vertexB, vertexC) }
val adj by derivedStateOf { distance(vertexA, vertexC) }
val hyp by derivedStateOf { distance(vertexA, vertexB) }
val sin by derivedStateOf { opp / hyp }
val cos by derivedStateOf { adj / hyp }
val tan by derivedStateOf { opp / adj }
The properties vertextA
, vertextB
, vertextC
are also derivedStateOf
properties… This currently works but I’m concerned that I’m introducing subtle bugs and I don’t realize it.romainguy
05/12/2025, 4:08 PMJonathan
05/12/2025, 4:09 PMdistance
is just a call to Math.hypot(...)
romainguy
05/12/2025, 4:10 PMromainguy
05/12/2025, 4:10 PMJonathan
05/12/2025, 4:13 PMmutableStateOf
because I set them from my Composable when the I detect taps/drags. Wouldn't I need "derived" state to allow calling code to observe changes to trig info?romainguy
05/12/2025, 4:14 PMromainguy
05/12/2025, 4:15 PMromainguy
05/12/2025, 4:15 PMJonathan
05/12/2025, 4:16 PMromainguy
05/12/2025, 4:16 PMJonathan
05/12/2025, 4:17 PMtan
or cos
since they are not State
?shikasd
05/13/2025, 4:12 AM