Alexander Maryanovsky
06/06/2022, 8:01 AMmyanmarking
06/06/2022, 8:21 AMxxfast
06/06/2022, 8:25 AM@Composable
, do it elsewhere (maybe ViewModel)
Alexander Maryanovsky
06/06/2022, 8:31 AMBwaim
06/06/2022, 9:36 AMstateIn
operator on FlowAlexander Maryanovsky
06/06/2022, 11:37 AMAlexander Maryanovsky
06/06/2022, 11:40 AMstateIn
, but I wrote a helper combineStateFlows
function which takes `StateFlow`s and a transform function, and sets the initial value to the transform of the state flow’s values at the time of the call.Alexander Maryanovsky
06/06/2022, 11:41 AMArjan van Wieringen
06/06/2022, 12:12 PMStylianos Gakis
06/06/2022, 12:13 PMval one: StateFlow<String>
val two: StateFlow<String>
val state = combine(one, two) { one, two ->
one to two
}.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5.seconds),
one.value to two.value,
)
is perfectly fine, I don’t think it’s a bad idea.Alexander Maryanovsky
06/06/2022, 12:24 PMStylianos Gakis
06/06/2022, 1:30 PM.value
on all StateFlows instead.Alexander Maryanovsky
06/06/2022, 1:34 PM