Other than the obvious of passing it in as a param...
# coroutines
s
Other than the obvious of passing it in as a parameter?
g
It also may be extension function of CorroutineScope (same as launch/async), but it depends on your use case
s
but a suspend function doesn't have access to the existing CoroutineScope (caller's) unless it's passed in?
g
yes
There are ways to implicitly connect to scope lifecycle (get Job from coroutineContext and set it as parent job) and just use GlobalScope
But it’s more about your use case and semantics
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