Can we create flow in different dispatcher and col...
# coroutines
v
Can we create flow in different dispatcher and collect flow in the different dispatcher, I was playing around while learning flow and wrote a code, Can someone explain
output
Oh, I think I am doing this the whole time, like changing context through
flowOn(dispatcher)
, and receiving in runBlocking{} scope which is in
main dispatcher
😅, correct me if wrong
g
Yes, it's correct
Though you run blocking explicitly running on Default dispatcher (btw you can pass dispatcher directly to run blocking without with context)
v
okay thanks
g
also keep in mind that context and thread is not the same, it can be different context, different dispatcher, but the same thread
IO and Default dispatchers share pool of threads
v
oh, yes, a thread is a big thing and then we can have different contexts and dispatchers to dispatch coroutine to another thread, am I understanding this right?
g
we can have different contexts and dispatchers to dispatch coroutine to another thread
Not sure what you mean My point that the same context or even the same dispatcher doesn’t mean that the same thread will be used, and opposite also true, different context and dispatchers doesn’t necessary mean that different thread will be used
v
okay I am getting it