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;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.
reset: object;Model state was cleared via Model.reset.