Kotlin Coroutines Detect Cancellation Callback

January 31, 2020
scope.launch {
    // do something
}
.invokeOnCompletion { e ->
    if (e != null && e is CancellationException) {
        // cancelled
    }
}

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.