kotlinx.coroutines
kotlinx.coroutines copied to clipboard
Investigate possible shortcuts for `coroutineContext.job.invokeOnCompletion { if (it != null) ... }`
trafficstars
The pattern itself is useful for any closeable resources that face non-atomic cancellation (https://github.com/Kotlin/kotlinx.coroutines/issues/1191) as the only reliable way to close it.
Apart from that, the pattern itself is very clunky, but seems to be quite frequent: [1], [2].
We should investigate whether we can provide more convenient extensions on top of CoroutineContext and CoroutineScope