# Workbook.onChange Method

> Workbook.onChange method in the TX Sheet Control JavaScript API for Node.js, with the return type () => void and a JavaScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Sheet Control > API Reference > JavaScript API > Node.js Server > Workbook > Workbook.onChange Method
- **377 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/onchange-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/onchange-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/onchange-method/llms-full.txt

---

The onChange operation of Workbook.

Owner: [Workbook](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/llms-full.txt). Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

### Syntax

```javascript
owner.onChange(listener)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `listener` | `(event: WorkbookChange) => void` | No | Value matching listener'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.

```javascript
function observeInvoiceEdits(control) {
    const book = control.workbook;
    const unsubscribe = book.onChange((change) => console.log(change.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

- [Workbook Class](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/llms-full.txt)
- [Events and Cancellation](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/events/llms-full.txt)
- [WorkbookChange Interface](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookchange/llms-full.txt)

---

## Nearby

- **Previous:** [Workbook.names Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/names-property/llms-full.txt)
- **Next:** [Workbook.previewConsolidate Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbook/previewconsolidate-method/llms-full.txt)
