I'm trying the new kotlinx 0.26.0 toys, I struggel...
# coroutines
d
I'm trying the new kotlinx 0.26.0 toys, I struggel on something. I had a
Job
that I used as a parent for coroutines in this class. At some point I did a
job.join()
to make sure all operations were over. Now, I made this class implement
CoroutineScope
, I run some operations in
launch(Dispatchers.Main+job)
But
job.join()
is not effective anymore, and I cannot use
coroutineContext[Job]
for it. How should I do to have a 'global'
Job
which I could use?
e
You
CoroutineScope
implementation should return
Dispatcher.Main+job
as its
coroutineContext
and then you can simply
launch { ... }
in this class.
job.join()
should work as before. Share a piece of your code in a gist if it does not.
d
Actually, it's
<http://Dispatchers.IO|Dispatchers.IO>+job
And
job.join()
still doesn't resume 😞 Also, the
launch(Dispatchers.Main+job)
is in a child class. Could it be the cause? `coroutinecontext should still be the same
e
Can you write some small self-contained reproducer?
d
yep, so it doesn't I reproduce in the very same instance, here is a gist: https://gist.github.com/GeoffreyMetais/cf68d2e2c80964f92452786596e076b1 I was just preparing it 🙂
job.joinChildren()
seems to do what I want. Am I correct?