https://kotlinlang.org logo
Title
k

KayCee

09/10/2020, 8:45 AM
What would be like in coroutines in case I want to do one job first -> wait that to finish -> then 2 other jobs later?
g

gildor

09/10/2020, 9:26 AM
launch { doSomething() // suspend function launch { doSomethingElse1() } launch { doSomethingElse2() } }
or if you want to be a bit more explicit (and you also need result of those 2 jobs, if they has the same type)
doSomething()

awaitAll(
  async { doSomethingElse1() },
  async { doSomethingElse2() },
)
👍 1
j

Joffrey

09/10/2020, 4:36 PM
trailing comma… living on the edge🤘
😆 4
g

gildor

09/11/2020, 12:57 AM
Actually we didn’t migrate to Kotlin 1.4, just copy-paste 😆 One more confirmation why trailing coma is a good language feature 🙈
🤔 1
r

Rechee Jozil

09/12/2020, 7:27 AM
Not sure what you mean by two jobs later, but you can just launch and do 3 suspend functions. One won't be executed until the previous competes
👍 1
k

KayCee

09/13/2020, 1:04 PM
Yeah. Just a thought in mind. I aint do it yet. Still looking for a complete solution :))