Files
bitburner-src/markdown/bitburner.ns.atexit.md

864 B

Home > bitburner > NS > atExit

NS.atExit() method

Add a callback to be executed when the script dies.

Signature:

atExit(f: () => void, id?: string): void;

Parameters

Parameter Type Description
f () => void A function to execute when the script dies.
id string (Optional) Callback ID. Optional, defaults to "default".

Returns:

void

Remarks

RAM cost: 0 GB

Each script can only register one callback per callback ID. If another callback is registered with the same callback ID the previous callback with that ID is forgotten and will not be executed when the script dies.