Skip to content

finalizer

The finalizer() function registers a final callback collected by the flow runner. It is designed for end-of-flow logic that should stay inside the flow effect system.

Interactive example

Syntax

typescript
function finalizer<
	GenericOutput extends unknown
>(
	theFunction: () => GenericOutput
): Generator<Finalizer<GenericOutput>, undefined>

Parameters

  • theFunction: Callback collected by the runner and executed when the flow finishes.

Return value

A generator yielding a finalizer effect. The callback result is handled by the runner, not by the flow body.

See also

  • defer - Registers a cleanup callback
  • run - Collects and executes finalizers

Released under the MIT license.