Is there anything wrong with getting the value of ...
# compose
n
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
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()
n
thanks 🙂