# WorkbookEvents Class

> WorkbookEvents class in the TX Sheet Control JavaScript API for Node.js: Per-document typed subscriptions. Covers 2 methods and a JavaScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > JavaScript API > Node.js Server > WorkbookEvents Class
- **625 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/llms-full.txt

---

Per-document typed subscriptions. Callbacks are excluded from saved state and undo history.

Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

Related workbook object-model type, returned through the server control. Obtain it from its owning workbook or collection; it is not a required browser-package import.

### Constructor

```javascript
new WorkbookEvents()
```

This overload has no parameters.

Returns: `WorkbookEvents`.

### Members

#### Methods

| Method | Description |
|---|---|
| [on](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/on-method/llms-full.txt) | Registers a listener and returns an idempotent unsubscribe function. |
| [once](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/once-method/llms-full.txt) | Registers a listener that unsubscribes before its first invocation. |

### Examples

Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.

```javascript
function createWorkbookEventsReport(control) {
    const book = control.workbook;
    const sheet = book.sheets.at(0);
    const changes = [];
    const unsubscribe = book.events.on('changed', (event) => changes.push(JSON.stringify(event)));

    try {
        sheet.cell('A1').setText('October invoice');
        sheet.cell('A1').format({
            fontFamily: 'Liberation Sans',
            fontSize: 16,
            bold: true,
            textColor: '#ffffff',
            fillColor: '#163b63',
        });

        sheet.columns.at(0).setWidth({ pixels: 240 });
    } finally {
        unsubscribe();
    }

    return changes;
}
```

### See Also

- [JavaScript Node.js Server API](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/llms-full.txt)
- [Events and Cancellation](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/events/llms-full.txt)

---

## In This Section

- [WorkbookEvents.on Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/on-method/llms-full.txt): WorkbookEvents.on method in the TX Sheet Control JavaScript API for Node.js: Registers a listener and returns an idempotent unsubscribe function.
- [WorkbookEvents.once Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/once-method/llms-full.txt): WorkbookEvents.once method in the TX Sheet Control JavaScript API for Node.js: Registers a listener that unsubscribes before its first invocation.

---

## Nearby

- **Previous:** [WorkbookCalculation.setExternalWorkbook Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/setexternalworkbook-method/llms-full.txt)
- **Next:** [WorkbookEvents.on Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookevents/on-method/llms-full.txt)
