Is there anything wrong with getting the value of a state right away and consuming throughout the composable tree?
Copy code
val buttonStateValue = myViewModel.buttonState.collectAsState().value
MyScreen(buttonStateValue)
....MyScreen consumes the buttonStateValue, and passes it down to a bunch of other composables
c
Casey Brooks
10/22/2021, 4:24 PM
Nope, that's all the
getValue()
extension delegate is doing under the hood. There's functionally no difference.
But you can save yourself a
.value
by using the delegate, which looks a bit cleaner:
val buttonStateValue by myViewModel.buttonState.collectAsState()