Example code being referenced:
viewModelScope.launch {
delay(5000)
...
}
Page 233 states:
Because delay is running inside a coroutine, during the five seconds that the function is counting milliseconds your UI is still capable of drawing any new updates and can instantly respond to user input
I think it might be beneficial to explain the nuance of the fact that viewModelScope.launch is executing on the main thread, and the only reason the UI isn’t blocked is because we are calling a suspend fun (delay) that itself dispatches off the main thread. The quoted explanation above makes it sound as though any arbitrary blocking code could be added inside viewModelScope.launch without blocking the UI.
References:
[1] android - Does block inside viewmodelscope runs on Main thread or background thread? - Stack Overflow
[2] Các phương pháp hay nhất cho coroutine trong Android | Kotlin | Android Developers