Gabriel Melo
02/22/2022, 5:26 PM.map
operator or something similar to a StateFlow
and get another StateFlow
back?Sam
02/22/2022, 5:27 PMSam
02/22/2022, 5:28 PMmap { ... }.stateIn(...)
Gabriel Melo
02/22/2022, 5:34 PMGabriel Melo
02/22/2022, 5:35 PMGabriel Melo
02/22/2022, 5:36 PMSam
02/22/2022, 5:46 PMStateFlow
. I can see that it's inconvenient to have to provide a CoroutineScope
, but I think it's unavoidable. Since the resulting StateFlow
is a shared flow, the work to compute its values always has do be done by the producer, not by the consumer.Sam
02/22/2022, 5:48 PMGabriel Melo
02/22/2022, 5:50 PMGabriel Melo
02/22/2022, 5:53 PMSam
02/22/2022, 5:57 PMMutableStateFlow
then whatever code you write to set values on that flow is acting as the producer. It may not necessarily be a coroutine, but something besides the consumer is doing the work to provide the values.Sam
02/22/2022, 5:57 PMStateFlow
by hand, by collecting values from the flow and setting them on a MutableStateFlow
, you'd have to launch a coroutine to do that.Joffrey
02/22/2022, 6:02 PMGabriel Melo
02/22/2022, 6:05 PM