dispose
@rotorsoft/act-root / act/src / dispose
Function: dispose()
dispose(
disposer?): (code?) =>Promise<void>
Defined in: libs/act/src/ports.ts:285
Registers a cleanup function for graceful shutdown.
Disposers are called automatically on SIGINT, SIGTERM, uncaught exceptions, and unhandled rejections. They execute in reverse registration order before port adapters are disposed.
Parametersโ
disposer?โ
Async function to call during cleanup. Omit to get a reference to disposeAndExit without registering.
Returnsโ
Function to manually trigger disposal and exit
(code?) => Promise<void>
Exampleโ
import { dispose } from "@rotorsoft/act";
const db = connectDatabase();
dispose(async () => await db.close());
// In tests
afterAll(async () => await dispose()());
Seeโ
disposeAndExit for the full shutdown sequence