what is similar to C#‘s `Task.WhenAll()` in kotlin...
# coroutines
d
what is similar to C#‘s
Task.WhenAll()
in kotlin?
d
if you tell us what this method means in c# 😉
k
i'm not sure if this is exactly what you need but WhenAll sounds like CompletableFuture.allOf
and small example
Copy code
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.future.future
import java.util.concurrent.CompletableFuture
import kotlin.system.measureTimeMillis

fun main(args: Array<String>) {
    val time1 = measureTimeMillis {
        listOf(1, 2, 3)
                .map { i -> future { delay(i * 1000L); 42 } }
                .map { it.get() }
    }
    println("Completed in $time1 ms")

    val time2 = measureTimeMillis {
        val tasks = listOf(1, 2, 3)
                .map { i -> future { delay(i * 1000L); 42 } }
        CompletableFuture.allOf(*tasks.toTypedArray()).get()
    }
    println("Completed in $time2 ms")
}