launchOnCancellation

fun Job.launchOnCancellation(block: suspend () -> Unit): CompletableJob

Launch a coroutine with block body when either the parent job or the returned job is cancelled. It is important to complete or cancel the returned CompletableJob otherwise the parent job will be unable to complete successfully.