Hi guys, QQ: I’ve this ```class Foo { suspendin...
# coroutines
t
Hi guys, QQ: I’ve this
Copy code
class Foo {
   suspending fun foo() { /* some code */ }
And inside it I would like to launch some child coroutines (and await their ending, so, like
coroutineScope {}
), what’s the correct pattern for it? I’ve seen people using
class Foo : CoroutineScope
to be able use use launch or coroutineScope directly, but what does this actually do?
a
You can run
coroutineScope
within any suspending function, no need to have a CoroutineScope receiver- it will create a new Job with a parent from the current context’s Job
❤️ 1
Having a CoroutineScope receiver just allows
launch
etc to be able to access a context when run from a non-suspending function- the CoroutineScope interface is basically just a
coroutineContext
property
t
You can run 
coroutineScope
 within any suspending function
didn’t notice that 🤦 thanks!