Код: Выделить всё
fun findNameById(id: Long): String {
var name = ""
viewModelScope.launch(Dispatchers.IO) {
val result = async { repository.findName(id) }.await()
name = result
}
return name
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -coroutine
Мобильная версия