When to call async{}.join() in Kotlin?

Hi

I noticed that async {} also has .join() beside .await().

My question is: when will we call .join() instead of .await()?

Thanks

1 Like

It is not async, it is https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/. It inherits a Job so it has the same methods. In some cases, you could want to wait for something to compute and use its results elsewhere. But in general it is just for API consistency.

1 Like