Title
d

Daniel Tam

04/13/2018, 12:37 PM
Anyone know if there is a Promise.all() equivalent for
Deferred<T>
?
l

louiscad

04/13/2018, 12:39 PM
d

Daniel Tam

04/13/2018, 12:44 PM
ahhh makes sense
I was getting confused because I was trying to do it from a non suspending function
but I guess I can put that map call inside an
async
call
sorry I'm literally just learning about coroutines properly now, but thanks!
l

louiscad

04/13/2018, 12:53 PM
@Daniel Tam I guess the most efficient way is to do:
arrayOf(
    async(coroutineContext) { ... },
    async(coroutineContext) { ... },
    async(coroutineContext) { ... }
).map { it.await() }
👍 2
d

Daniel Tam

04/13/2018, 1:57 PM
a forEach makes more sense actually right
l

louiscad

04/13/2018, 2:00 PM
@Daniel Tam You're right. If you don't need a list of the results, a
forEach
on an array is even more efficient