```val aFlow = emptyFlow<String?>() val delegation...
# compose
j
Copy code
val aFlow = emptyFlow<String?>()
val delegationValue by aFlow.collectAsState(initial = null)
val directValue = aFlow.collectAsState(initial = null).value
Is there a difference in these 2 setups outside the fact that the second option doesn't require enforcing non-nullability using
!!
as smart casting works properly due to not being delegated? Or will there be performance tradeoffs and/or behavioral differences as well?
j
You're changing the place where you do the state read. So a change to
directValue
would trigger recomposition in the same scope that you do
collectAsState
instead of the scope where you would use
delegationValue
.
j
Yes so basically, if I read it within the same scope it should be fine right?
Decided to just use "by", solves a lot of issues at the only cost of enforcing non-nullability using !!. Thanks for your reply/information