arrow-fx-coroutines / arrow.fx.coroutines / onCancel

onCancel

suspend inline 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

guarantee

guaranteeCase

Do you like Arrow?

Arrow Org
<