adte
04/05/2023, 11:07 PMDerek Ellis
04/05/2023, 11:17 PMcollectAsState()
?adte
04/05/2023, 11:21 PMfirst()
method actually to get the first valueDerek Ellis
04/05/2023, 11:23 PMmapToOne()
or mapToOneOrNull()
functions
Those will give you Flow<T>
and Flow<T?>
respectivelyadte
04/05/2023, 11:23 PMT
so that any part of my UI can just access that variable or use it to query child items etc.
But a Flow
is more like a channel where you wait for data to come inadte
04/05/2023, 11:26 PMcollectAsState
does, just have to call it in my *State classadte
04/06/2023, 1:21 AMcollectAsState
can only be called from a Composable. So it seems I want to use stateIn
to convert the flow to a StateFlowglureau
04/06/2023, 6:51 AMStylianos Gakis
04/06/2023, 8:03 AMStateFlow
in wherever you are holding your state, and then on the UI layer you can both observe it and even get it instantly by using the value
field that StateFlow
exposes.adte
04/06/2023, 6:30 PMglureau
04/06/2023, 6:41 PMadte
04/06/2023, 6:57 PM