Spheniscine
03/23/2022, 4:35 AMrocketraman
03/23/2022, 12:36 PMstate variables are single objects, not those annoying (value, setValue) tuples that have to be passed around everywhere, and where setValue doesn't actually change the immutable value variable until recompositionKeep in mind Compose works the same way when you use the decomposition style of state declaration, which is often useful when hoisting state:
val (value, setValue) = remember { mutableStateOf(default) }
Spheniscine
03/23/2022, 1:25 PMandylamax
03/24/2022, 2:09 AMval (value,setValue) by . . .
syntax exists, but that is just syntax to mimic react applications. Under the hood, it is not implemented that way at all. Which going back to the point, one of the things Compose got rightrocketraman
03/24/2022, 3:34 AMvar
which doesn't feel idiomatic to me). In fact at one point Leland Richardson was considering making it the only way to access state: https://twitter.com/intelligibabble/status/1476612660716208132.
Furthermore, regardless of the under the hood implementation, because the decomposed value
is a val
it is immutable — setValue
doesn't change it until recomposition, which was the OP's original complaint:
setValue doesn't actually change the immutable value variable until recomposition
Spheniscine
03/24/2022, 4:30 AMSpheniscine
03/24/2022, 4:31 AM