Join Slack
Powered by
can I collect on a flow using main dispatcher? is ...
# coroutines
r
Remon Shehata
09/11/2023, 6:58 PM
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
Pablichjenkov
09/11/2023, 7:04 PM
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
Remon Shehata
09/11/2023, 7:07 PM
got it.. thank you
9
Views
Open in Slack
Previous
Next