I have code like
viewModelScope.launch(exceptionHandler) {
withContext(Dispatchers.IO){
val name = fetchName() //suspend fun
val surname = fetchSurname() //suspend fun
}
//how to wait response from name and surname to use it in another call?
//name and surname must be async
}
private suspend fun fetchName(): Name {
return withContext(Dispatchers.IO) {
//db
}
}
private suspend fun fetchSurname(): Surname {
return withContext(Dispatchers.IO) {
//db
}
}
How to wait response from name and surname to use it in another call?