Skip to main content

dispose

@rotorsoft/act-root


@rotorsoft/act-root / act/src / dispose

Function: dispose()

dispose(disposer?): (code?) => Promise<void>

Defined in: libs/act/src/ports.ts:250

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?

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