reactormonk
05/21/2024, 2:51 PMasync(<http://Dispatchers.IO|Dispatchers.IO>) { ... }.await() and withContext(<http://Dispatchers.IO|Dispatchers.IO>) { ... }? And how can I ensure they don't run on the main thread (hello Android)?jw
05/21/2024, 2:55 PMwithContext moves the current coroutineSam
05/21/2024, 2:55 PMIs there a difference…?Using
async with an immediate await() doesn't make a lot of sense and isn't something I'd ever do deliberately. If you write that, IntelliJ IDEA will suggest you change it to the second version, with withContext.
And how can I ensure they don't run on the main thread?By using
<http://Dispatchers.IO|Dispatchers.IO>, you are telling it not to run on the main thread.jw
05/21/2024, 2:55 PMreactormonk
05/21/2024, 2:55 PM