I'm using kotlin coroutines to get responses from server in android with viewmodel. The problem is that i want to get two different requests responses to update ui but wanna execute them concurrently and wait for both of them to finish. then update the ui with all of the result received. If using async and await after each request it will execute one by one and it's not concurrent and if using map of requests and awaitAll(), i can't handle multiple data types (data classes) because the data types of two requests are different. It could be more that two requests. What can i do for this situation ?
val job = viewModelScope.launch {
val a = async { firstUseCase.execute() }.await()
val b = async { secondUseCase.execute() }.await()
}