hfhbd
03/20/2022, 2:18 PMsharedFlow
builder with the same signature like the cold flow
builder: fun<T> sharedFlow(block: suspend FlowCollector<T>): SharedFlow<T>
? It always requires a CoroutineScope
...ephemient
03/20/2022, 2:24 PMsharedFlow.collect() // in scope 1
sharedFlow.collect() // in scope 2 in parallel
then cancelled one of the scopes, in what scope should the single shared producer be running?hfhbd
03/20/2022, 2:30 PMfun<T> sharedFlow(block: MutableSharedFlow<T>.() -> Unit): SharedFlow<T> = MutableSharedFlow<Int>().apply(block)
val sf = sharedFlow {
tryEmit(42)
}
But would like to use emit
(and FlowCollector) instead.ephemient
03/20/2022, 2:32 PMsf
were a plain flow
, then tryEmit
runs as a child within the scope of each collectorSharedFlow
, there should be a single coroutine running tryEmit
regardless of how many parallel collectors there arehfhbd
03/20/2022, 2:39 PMephemient
03/20/2022, 2:40 PMhfhbd
03/20/2022, 2:42 PMOrhan Tozan
03/27/2022, 11:05 PMhfhbd
03/28/2022, 10:34 AMSharedFlow
.Orhan Tozan
03/28/2022, 10:35 AMSharedFlow
?hfhbd
03/28/2022, 10:42 AMOrhan Tozan
03/28/2022, 10:44 AMhfhbd
03/28/2022, 10:53 AMOrhan Tozan
03/28/2022, 10:56 AMhfhbd
03/28/2022, 11:07 AMbroadcast
and want to migrate it to SharedFlow. Why should I use produce
?Orhan Tozan
03/28/2022, 11:18 AM