if i have a function ``` fun asyncFetchFoo(id: Str...
# coroutines
r
if i have a function
Copy code
fun asyncFetchFoo(id: String) = async { ... }
which returns a
Deferred<String>
What is a clean way to invoke the fetching concurrently and still map each result back to the corresponding
id
without intermediate maps? If I have:
Copy code
val ids = listOf("a","b","c","d")
val linksById = ids.associateBy({ it.id },{asyncFetchFoo(it.id)})
val results = ids.map { it + "=" + linksById[it].await() }
What is a clean pattern to avoid the
linksById
map and still invoke asyncFetchFoo concurrently?