inline suspend fun <A> onCancel(fa: suspend () -> A, crossinline onCancel: suspend () -> Unit): A(source)

Registers an onCancel handler after fa. onCancel is guaranteed to be called in case of cancellation, otherwise it's ignored.

This function is useful for wiring cancellation tokens between fibers, building inter-op with other effect systems or testing.

See also

for registering a handler that is guaranteed to always run.

for registering a handler that executes for any ExitCase.



program that you want to register handler on


handler to run when fa gets cancelled.