vapoyan
04/03/2021, 3:13 PMsuspend methods and returning a Double result.
How I can organise the code so calculateResult() method is called ONLY when resultDoSomething1 and resultDoSomething2 are received from the server. (without booleans)
val resultDoSomething1: Double = 0.0
val resultDoSomething2: Double = 0.0
fun doSowmthing1() {
iewModelScope.launch {
resultDoSomething1 = downloadDataFromServer1()
}
}
fun doSowmthing2(){
iewModelScope.launch {
resultDoSomething2 = downloadDataFromServer2()
}
}
fun calculateResult() {
val res = resultDoSomething1 + resultDoSomething2
}Nikhil
04/03/2021, 3:23 PMErnestas
04/03/2021, 6:06 PM