onCancel

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

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.

Parameters

fa

program that you want to register handler on

onCancel

handler to run when fa gets cancelled.

See also

for registering a handler that is guaranteed to always run.

for registering a handler that executes for any ExitCase.