# WorkbookEvents.once Method

> WorkbookEvents.once method in the TX Sheet Control TypeScript API for the browser: Registers a listener that unsubscribes before its first invocation.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Sheet Control > API Reference > TypeScript API > Browser Editor > WorkbookEvents > WorkbookEvents.once Method
- **509 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookevents/once-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookevents/once-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookevents/once-method/llms-full.txt

---

Registers a listener that unsubscribes before its first invocation.

Owner: [WorkbookEvents](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookevents/llms-full.txt). Package: `@txtextcontrol/tx-sheet-control`. Version: **2.0.0**.

### Syntax

```typescript
once<Key extends keyof WorkbookEventMap>(name: Key, callback: (event: WorkbookEventMap[Key]) => void): () => void
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `name` | `Key` | No | Name validated in the owning collection or document scope. |
| `callback` | `(event: WorkbookEventMap[Key]) => void` | No | Value matching callback's declared type and the owning object's validation rules. |

### Return Value

`() => void`.

### Examples

Use a fresh sample workbook for this example. In the browser pass editor.workbook; in Node.js pass the server control. Document-bound objects are obtained from that same owner.

```typescript
import type { Workbook } from '@txtextcontrol/tx-sheet-control';

function observeInvoiceChanges(book: Workbook) {
    const unsubscribe = book.events.once('changed', (event) => console.log(event.source));
    return unsubscribe;
}
```

### Remarks

Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.

### See Also

- [WorkbookEvents Class](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookevents/llms-full.txt)
- [Events and Cancellation](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/events/llms-full.txt)
- [WorkbookEventMap Interface](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookeventmap/llms-full.txt)

---

## Nearby

- **Previous:** [WorkbookEvents.on Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookevents/on-method/llms-full.txt)
- **Next:** [WorkbookFeatures Interface](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/workbookfeatures/llms-full.txt)
