https://kotlinlang.org logo
#flow
Title
# flow
c

christiangruber

01/08/2020, 11:07 PM
Hey - I'm having some struggles thinking through flowOn() and the final collect operation. flowOn(SomeDispatcher) seems to configure the up-stream pipeline up to the point where teh pipeline element has a coroutine context already. Cool. But how do I configure
collect{}
to run in a particular context? Should I move what was done in a collect() to an onEach{} and then let collect{} just trigger final logging?
a

Albert Beade

01/15/2020, 10:34 AM
Hi @christiangruber, according with
collect
documentation (https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/collect.html), the
collect
operator is usually usued with
onEach
to process the emited items, so using it for that pourpose looks to me way to proceed. Hope this helps!
c

christiangruber

01/15/2020, 5:08 PM
Thanks. I got it working.
👍 1
3 Views