For instance I have 3 data source from different end-points. I'd like to call all of them in parallel and get the first answer (fastest), then other calls should be discarded. I know how do it using RxJava with Observable.amb(). How to implement it using Kotlin coroutines? The important thing is - no need to wait other calls after the first result.
suspend fun dataSourceOne(){
delay(1_000L)
}
suspend fun dataSourceTwo(){
delay(2_000L)
}
suspend fun dataSourceThree(){
delay(3_000L)
}
// should call [dataSourceOne(), dataSourceTwo(), dataSourceThree()] in parallel
// and discard [dataSourceTwo(), dataSourceThree()] after the getting a result from dataSourceOne()
PS: Android application.