The type behind on and off. There are two emitters, and subscribing to the wrong one is silent. Document lifecycle events are global and fire on Kernstra.events; everything else is per-viewer and fires on viewer.on(...). A handler registered on the wrong emitter never runs and never warns. Each emitter is typed by its own map — GlobalEventMap for Kernstra.events, ViewerEventMap for viewer.on — so subscribing to a viewer event on the global emitter, or the reverse, is a compile error rather than a handler that never runs. SDKEventMap is both together, for a payload typed by name (SDKEventMap['pageChanged']). Every event and its payload is listed under Events.
Kernstra.events offers on and off only (the exported GlobalEvents type): only the SDK emits on it. EventEmitter is exported because it is the type behind on and off, not as a channel to emit through; its emit and removeAllListeners are the SDK's own. A handler that throws is logged and does not stop the others. Kernstra.destroy() leaves what is subscribed to Kernstra.events in place: a handler registered at module level hears the next init()'s initialized without subscribing again, and Kernstra.events is the same emitter for the page's life. No member needs a license feature or a document.
Subscribe to a typed event. on() returns the unsubscribe; Kernstra.events.on takes the same options as viewer.on.
Parameter
Type
Description
event
K
An event name of this emitter's map: GlobalEventMap on Kernstra.events, ViewerEventMap on a viewer.
handler
EventHandler<T[K]>
Receives the typed payload. One that throws is logged and does not stop the others.
options?
SubscribeOptions
{ once?: boolean; signal?: AbortSignal }. once hears the next emit only; signal unsubscribes when the AbortSignal aborts, so one AbortController can end every subscription a component made (a signal already aborted subscribes nothing).
The SDK's own: calls every handler of the event synchronously, in the order they subscribed; one that throws is logged and does not stop the others. Kernstra.events exposes on and off only.
The SDK's own: drops every handler of every event, as a viewer's destroy() does. Kernstra.events exposes on and off only, so a host cannot drop every other subscriber.