can I collect on a flow using main dispatcher? is ...
# coroutines
r
can I collect on a flow using main dispatcher? is this code correct or would it block the main thread?
Copy code
CoroutineScope.launch(Dispatchers.Main){

flow.collect{}

}
p
It is correct , it will execute on the main thread. Doesn't mean it blocks, it just collects the flow on the main thread. The code you write in the collect {} block executes on main thread.
r
got it.. thank you