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

bj0

09/20/2018, 4:33 PM
when you create a
CoroutineScope
object, is there a way to wait for it to finish (like
coroutineScope
waits)?
e

elizarov

09/20/2018, 6:27 PM
Use
coroutineScope { ... }
to wait. If you need an “object”, use
async { ... }
and then
.await
on its result
b

bj0

09/20/2018, 6:56 PM
What I mean is say I create a class
Connection
that implements
CoroutineScope
like the example activity in the docs. Then I have some service create that object and start it, since I'm not using
coroutineScope
, nothing is inherited and it's not a child, so is there a way to wait for it's scope to complete?
Only thing I can think of is access the
Job
directly and
.join
, but I was wondering if there was something specific to scopes that would make that unnecessary
e

elizarov

09/20/2018, 9:48 PM
Join the job that is
5 Views