Is there any way to prevent a coroutine from being...
# coroutines
a
Is there any way to prevent a coroutine from being cancelled when its
Job
is cancelled but still having it be cancelled if the parent job is cancelled. Here is a short snippet showcasing the issue:
Copy code
val job = launch {
  delay(400.milliseconds)
  showView()
  try {
    // Ideally I would like this part to mean job.cancel() has no effect
    // but if the parent job is cancelled it should cancel immediatly
    withContext(NonCancellable) {
      delay(400.milliseconds)
    }
  } finally {
    hideView()
  }
}