import type { Task } from "../../Task/model"; import type { Managed } from "../model"; import { onExitFirst, onExitFirst_ } from "./onExitFirst"; /** * Ensures that `f` is executed when this `Managed` is finalized, before * the existing finalizer. * * For use cases that need access to the Managed's result, see `onExitFirst`. */ export function ensuringFirst( f: Task ): (self: Managed) => Managed { return onExitFirst(() => f); } /** * Ensures that `f` is executed when this `Managed` is finalized, before * the existing finalizer. * * For use cases that need access to the Managed's result, see `onExitFirst_`. */ export function ensuringFirst_( self: Managed, f: Task ): Managed { return onExitFirst_(self, () => f); }