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

edenman

09/17/2021, 2:10 AM
is there an equivalent to
flowOn
that takes a
CoroutineScope
? i basically want a way to have a
flow { }
block that runs inside an existing scope
feels like something that should be possible, i’m probably just not thinking of some super obvious way to do this
tried just passing
Scope.coroutineContext
but that crashes with
Flow context cannot contain job in it
e

elizarov

09/21/2021, 3:27 PM
flow
is cold. It should not be defined in the existing scope. But you can collect it in a scope that you have.
e

edenman

09/21/2021, 11:11 PM
right, i want to collect it on the main thread but run the computation in the
flow { }
block on a background thread
i guess i can just pass in the dispatcher to
flowOn
but i was trying not to deal with that because Dispatchers.IO isn’t in KMP
5 Views