https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

Robert Menke

04/17/2018, 1:39 PM
Sorry if this has been asked a million times, but is there a coroutines equivalent to javascript’s
Promise.all
in the standard library? Something kind of along the lines of this… but better 😛
Copy code
fun <T>all(list : List<suspend () -> T>) : Deferred<List<T>> {
    return async {
        list.map { async { it() } }
            .map { it.await() }
    }
}
short answer no
you can use a
forEach
instead of
map
if you don't care about the final result
r

Robert Menke

04/17/2018, 6:15 PM
Thanks for the link @spand
2 Views