Colton Idle
01/04/2023, 8:50 PMsuspend fun getTwoThingsInParrallel():List<String> {
apiService.oneLongTwo()
apiService.secondLongCall()
...
//do something with the result
}
Colton Idle
01/04/2023, 8:51 PMCLOVIS
01/04/2023, 8:52 PMsuspend fun foo(): List<String> {
coroutineScope {
listOf(
async { apiService.onLongTwo() },
aynsc { apiService.secondLongCall() }
).awaitAll()
}
}
CLOVIS
01/04/2023, 8:52 PMawaitAll
is bad practice 🤔CLOVIS
01/04/2023, 8:53 PMkevin.cianfarini
01/04/2023, 9:01 PMcoroutineScope
builder function is specifically for the parallel decomposition of work in conunction with async
, launch
and friends.gildor
01/05/2023, 1:51 AM