WorkbookEvents.on Method
Registers a listener and returns an idempotent unsubscribe function.
Owner: WorkbookEvents. Package: @txtextcontrol/tx-sheet-control-server. Version: 2.0.0.
Syntax
on<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.
import type { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';
function observeInvoiceChanges(control: ServerSheetControl) {
const book = control.workbook;
const unsubscribe = book.events.on('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.