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

allan.conda

02/05/2021, 8:42 AM
Any idea how I can improve this? I don’t need the first two vals, but I want to trigger the call at the same time
j

Javier

02/05/2021, 8:42 AM
Copy code
launch { getA() }
launch { getB() }
or
Copy code
val jobA = launch { getA() }
val jobB = launch { getB() }

joinAll(a, b)
a

allan.conda

02/05/2021, 8:44 AM
launch returns Job 🤔 I need the return value
j

Javier

02/05/2021, 9:02 AM
you said you doesn't need the first two vals, but the fact is yes I think 🤔
if not, you will break the parallelism
a

allan.conda

02/05/2021, 9:50 AM
Ah, sorry, I meant saving
deferredA
and
deferredB
seems too redundant. I’m wondering if something like this is possible
Copy code
val (a, b) = (async { getA() } to async { getB() }).awaitAll()
looking for a more concise way to represent simultaneous async calls
4 Views