Skip to main content

onSDKEvent

Receives general SDK-to-host events.

Overview​

Implement onSDKEvent in your delegate to receive events that the SDK sends to the host outside of the panel and overlay event channels. This method is optional — hosts that do not implement it simply do not receive these events and can rely on getAvailablePanels() to pull the panel list on demand instead.

The SDK currently sends one event type on this callback: rendered:channels, which reports the available panel list once it is ready and again whenever it changes.

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
panelsMaestroPanelType[]The available panel types in tab order, matching getAvailablePanels() by type. 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.

Example​

import {
IMaestroEventDelegate,
SDKEvent,
RenderedChannelsSDKEvent,
} 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);
}
}

// ... 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.
  • Both SDKEvent and RenderedChannelsSDKEvent are exported from @maestro_io/maestro-web-sdk.