Skip to main content

onSDKEvent

Receives general SDK-to-host events.

Method Signature​

onSDKEvent?(event: SDKEvent): void

Parameters​

ParameterTypeDescription
eventSDKEventThe SDK event. Discriminate on event.type to handle each event type.

Return Value​

This method does not return a value.

Events​

rendered:channels​

Emitted once the page configs are parsed and the panel list is set — before renderPanel is called — and again whenever the list changes. Changes that trigger a new emission include a panel being hidden through updateUserSettings or an event being added or removed in a multi-event session. Identical republishes are skipped.

The payload type is RenderedChannelsSDKEvent['payload']:

FieldTypeDescription
panelsPanelType[]The available panel types in tab order, matching getAvailablePanels() by type. Each entry is either a MaestroPanelType constant (for built-in panels) or a config-defined type string (for config-driven panels). Empty when the page has no panels.
eventMetaDataRecord<string, PageMetadata>Each loaded page's metadata, keyed by the page's event ID (external_field_1). Pages without an external_field_1, or whose config failed to load, are absent.

panel-layout:failed​

Emitted when a designed panel's layout cannot be drawn. The panel is excluded from the tab strip and from getAvailablePanels(); all other panels are unaffected. The SDK emits this event before sending rendered:channels, so the first rendered:channels payload already reflects the exclusion.

The payload type is PanelLayoutFailedSDKEvent['payload']:

FieldTypeDescription
panelTypestringThe panel type whose layout could not be drawn.
reason'failed' \| 'nothingToDraw' \| 'timeout'Why the layout was not drawn. failed: the layout file could not be downloaded, did not match its hash, or did not parse. nothingToDraw: no layout is published for this panel type. timeout: the layout was still loading when the tab strip settled.
urlstring \| nullThe layout file URL the page config points at, or null if none was configured.

Example​

import {
IMaestroEventDelegate,
SDKEvent,
RenderedChannelsSDKEvent,
PanelLayoutFailedSDKEvent,
} from "@maestro_io/maestro-web-sdk";

class MyDelegate implements IMaestroEventDelegate {
onSDKEvent(event: SDKEvent): void {
if (event.type === "rendered:channels") {
const { panels, eventMetaData } =
(event as RenderedChannelsSDKEvent).payload;
// Build or update breakout buttons for each available panel.
renderBreakoutButtons(panels);
} else if (event.type === "panel-layout:failed") {
const { panelType, reason, url } =
(event as PanelLayoutFailedSDKEvent).payload;
console.warn(`Panel "${panelType}" excluded — layout ${reason}:`, url);
}
}

// ... other required delegate methods
}

Notes​

  • onSDKEvent is optional. Hosts that do not implement it can use getAvailablePanels() to pull the panel list synchronously after userDidStartWatchingEvent resolves.
  • The SDKEvent type is a discriminated union. Narrow on event.type before accessing event.payload to ensure type safety as new event types are added.
  • SDKEvent, RenderedChannelsSDKEvent, and PanelLayoutFailedSDKEvent are all exported from @maestro_io/maestro-web-sdk.