ModelEventArgs
type ModelEventArgs = object;Map from event name to payload shape, indexing the events that Model.on can subscribe to. Each entry below documents the trigger and payload semantics for one event.
Example
Section titled “Example”model.on('error', ({ workbookName, error }) => { console.warn(`Error in ${workbookName}: ${error.message}`);});model.on('recalc', m => console.log('recalc finished', m.id));Properties
Section titled “Properties”addsheet
Section titled “addsheet”addsheet: object;A sheet was added to one of the model’s workbooks. Re-emitted from the
underlying Workbook; subscribing on the model auto-installs the
forwarder on every workbook in the model, including those attached
after subscription.
index: number;sheetName
Section titled “sheetName”sheetName: string;workbookName
Section titled “workbookName”workbookName: string;attach
Section titled “attach”attach: object;A workbook was attached to the model (Model.addWorkbook / Model.attachWorkbook).
workbookName
Section titled “workbookName”workbookName: string;beforerecalc
Section titled “beforerecalc”beforerecalc: Model;Emitted at the start of Model.recalculate, before any cell is recalculated. Payload is the model.
detach
Section titled “detach”detach: object;A workbook was detached from the model (Model.removeWorkbook).
workbookName
Section titled “workbookName”workbookName: string;error: object;A ModelError was raised during a model operation. seenBefore
is true when the same error fingerprint has been emitted previously
in this model’s lifetime, so consumers can deduplicate repeated errors.
error: ModelError;seenBefore
Section titled “seenBefore”seenBefore: boolean;type: string;workbookId
Section titled “workbookId”workbookId: string | undefined;workbookName
Section titled “workbookName”workbookName: string | undefined;listenererror
Section titled “listenererror”listenererror: object;Emitted when a listener for another event throws. Listeners run in order and one that throws
stops neither the others nor the engine call that emitted the event. With no listener for
this event the exception is logged with console.error, as is a throw from a listener for
this event itself. recalcEvent listeners are the exception: that stream is emitted from
inside cell evaluation and a throw there aborts the recalc and does not trigger listenererror
events.
error: unknown;event: string;metrics
Section titled “metrics”metrics: MetricsEvent;Function-call timing sample (one event per evaluated function or
operator) emitted by a workbook during cell evaluation. The model
re-emits a workbook’s metrics events when there are listeners on the
model; the wiring is installed on every workbook in the model, including
those attached after subscription.
native-update
Section titled “native-update”native-update: object;External workbook update from the host environment (e.g. GRID native),
announcing that the named workbook should be considered modified at
lastWrite. Apiary itself does not emit this event; it is forwarded by
the host so consumers can invalidate caches.
action
Section titled “action”action: string;lastWrite
Section titled “lastWrite”lastWrite: number;workbookId
Section titled “workbookId”workbookId: string | undefined;workbookName
Section titled “workbookName”workbookName: string | undefined;recalc
Section titled “recalc”recalc: Model;Emitted at the end of Model.recalculate. Payload is the model.
recalcEvent
Section titled “recalcEvent”recalcEvent: RecalcEvent;Per-cell recalculation event emitted during Model.recalculate (one event per recalculated cell, plus phase markers). Subscribe to trace recalculation; see RecalcEvent for the full payload shape.
removesheet
Section titled “removesheet”removesheet: object;Emitted by a workbook when a sheet is removed, before the recalc that follows.
index: number;sheetName
Section titled “sheetName”sheetName: string;workbookName
Section titled “workbookName”workbookName: string;renamesheet
Section titled “renamesheet”renamesheet: object;Emitted by a workbook when a sheet is renamed, before the recalc that follows.
index: number;newName
Section titled “newName”newName: string;oldName
Section titled “oldName”oldName: string;workbookName
Section titled “workbookName”workbookName: string;