MainNote.kt

March 18, 2026

The main thread is a promise

Compose and views touch the UI on one thread. A disk read does not belong there.

Where work waits

Dispatchers.Main is the promise that a state write will be seen by the next frame. A network call on that dispatcher holds the frame hostage.

withContext(Dispatchers.IO) is the ordinary move. The function stays suspend, so the caller still has to be a coroutine.

Danville · educational · 2018AboutDeskFAQOffice