Other than the obvious of passing it in as a parameter?
g
gildor
02/14/2019, 4:34 AM
It also may be extension function of CorroutineScope (same as launch/async), but it depends on your use case
s
sitepodmatt
02/14/2019, 5:00 AM
but a suspend function doesn't have access to the existing CoroutineScope (caller's) unless it's passed in?
g
gildor
02/14/2019, 5:18 AM
yes
gildor
02/14/2019, 5:19 AM
There are ways to implicitly connect to scope lifecycle (get Job from coroutineContext and set it as parent job) and just use GlobalScope
gildor
02/14/2019, 5:21 AM
But it’s more about your use case and semantics
gildor
02/14/2019, 5:22 AM
Most obvious and flexible way: pass CoroutineScope as parameter to function, so this function can start new coroute (background one!) that explicitly connected to lifecycle of passed scope