mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 16:52:55 +02:00
34 lines
879 B
Markdown
34 lines
879 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [atExit](./bitburner.ns.atexit.md)
|
|
|
|
## NS.atExit() method
|
|
|
|
Add a callback to be executed when the script dies.
|
|
|
|
**Signature:**
|
|
|
|
```typescript
|
|
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 <code>"default"</code>. |
|
|
|
|
**Returns:**
|
|
|
|
void
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 0 GB
|
|
|
|
NS2 exclusive
|
|
|
|
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.
|
|
|