is there some quick way to forward collection to a...
# coroutines
d
is there some quick way to forward collection to another flow? Something like
Copy code
val flowA: MutableSharedFlow<Int>

flowB.collectTo(flowA)
I know there's
shareIn
, but it creates a new flow, while I have an existing one.
j
I don't believe there is anything like
emitAll()
for
MutableSharedFlow
, but you may be able to do
flowB.collect(flowA::emit)
👍 1
d
good enough, thanks! 👍
z
MutableSharedFlow
implements
FlowCollector
so you should just be able to do
flowB.collect(flowA)
👍 1
j
Good point, I had missed that
d
Hm. I tried that, but it was highlighted as an error. Re-checked and it's because this overload of
collect
is marked with
@InternalCorouinteApi
...
j
Ah yes, it won't be marked internal anymore in coroutines 1.6.0 (or maybe RC3 if there is one)
👍 1