Colton Idle
03/04/2023, 7:32 AMColton Idle
03/04/2023, 7:35 AMfranztesca
03/04/2023, 9:12 AMJoffrey
03/04/2023, 9:34 AMcoroutineScope {
launch {
val title = fetchTitle()
showTitle(title)
}
launch {
val artist = fetchArtist()
showArtist(artist)
}
}
showThingAfterBoth()
Colton Idle
03/04/2023, 5:13 PMColton Idle
03/04/2023, 5:13 PMColton Idle
03/04/2023, 5:14 PMJoffrey
03/04/2023, 5:15 PMColton Idle
03/04/2023, 5:16 PMJoffrey
03/04/2023, 5:21 PMval (title, artist) = coroutineScope {
val deferredTitle = async {
val title = fetchTitle()
showTitle(title)
title
}
val deferredArtist = launch {
val artist = fetchArtist()
showArtist(artist)
artist
}
deferredTitle.await() to deferredArtist.await()
}
showThingAfterBoth(title, artist)
It's not terribly beautiful, but you get the idea.Pedro Alberto
03/06/2023, 9:17 AMJoffrey
03/06/2023, 9:18 AMPair
definitely isn't the best, for instance. Probably a proper data class becomes necessary pretty quickly.Pedro Alberto
03/06/2023, 9:21 AMuli
03/07/2023, 3:05 PMcollect
Joffrey
03/07/2023, 3:05 PM