Simon Lin
fun foo() { viewModelScope.launch { val inputList = listOf("a", "b", "c") val deferredList = mutableListOf<Deferred<String>>() repeat(3) { index -> deferredList += async { delay((1L..10000L).random()) inputList[index] } } val outputList = deferredList.map { it.await() } // a, b, c } }
Tijl
awaitAll
deferredList
buildList
Nick Allen
inputList.map { item -> async { doSuspendStuff(item) } }.awaitAll()
A modern programming language that makes developers happier.