map Async
Transforms all elements of the iterable concurrently.
For each element, launches a coroutine to apply the transform function.
Example:
val userIds = listOf(1, 2, 3)
val users = userIds.mapAsync { id ->
api.getUser(id) // asynchronous call
}
println(users)Content copied to clipboard
Note:
One coroutine is launched per element, avoid large collections.
If any transform fails, all other coroutines will be cancelled.