How can I support cancellation within a `suspend` ...
# coroutines
n
How can I support cancellation within a
suspend
function? If I don't use
launch/async
etc to launch anything
You either use cancellable suspending functions (yield, delay, etc) or check for isActive
n
Right, but if I'm just in a
suspend
function without any context, how should I do that? Maybe I misunderstand suspend functions but:
Copy code
suspend fun sample() {
   // no isActive
}
I could launch something but I don't want to potentially change scopes/dispatchers
e
coroutineContext.isActive
👌 1
n
Wow, I had no idea such a variable existed. Thank you!