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

onCancel

common 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.

See also

common

   
guarantee for registering a handler that is guaranteed to always run.
guaranteeCase for registering a handler that executes for any ExitCase.

Parameters

common

   
fa program that you want to register handler on
onCancel handler to run when fa gets cancelled.

Do you like Arrow?

Arrow Org
<