openrv-web / EventsAPI
Class: EventsAPI
Defined in: api/EventsAPI.ts:67
Constructors
Constructor
new EventsAPI(
session,_viewer):EventsAPI
Defined in: api/EventsAPI.ts:72
Parameters
session
Session
_viewer
Returns
EventsAPI
Methods
dispose()
dispose():
void
Defined in: api/EventsAPI.ts:284
Clean up all listeners and internal subscriptions. After calling this, the EventsAPI instance should not be used.
Returns
void
emitError()
emitError(
message,code?):void
Defined in: api/EventsAPI.ts:276
Emit an error event (for internal use by other API modules).
Parameters
message
string
Human-readable error description.
code?
string
Optional machine-readable error code.
Returns
void
getEventNames()
getEventNames():
OpenRVEventName[]
Defined in: api/EventsAPI.ts:160
Get the list of all valid event names that can be subscribed to.
Returns
An array of valid event name strings.
Example
const names = openrv.events.getEventNames();off()
off<
K>(event,callback):void
Defined in: api/EventsAPI.ts:122
Unsubscribe a specific callback from an event.
Type Parameters
K
K extends OpenRVEventName
Parameters
event
K
The event name to unsubscribe from.
callback
EventCallback<OpenRVEventData[K]>
The exact callback reference that was passed to on.
Returns
void
Example
openrv.events.off('frameChange', myHandler);on()
on<
K>(event,callback): () =>void
Defined in: api/EventsAPI.ts:92
Subscribe to an event. The callback is invoked each time the event fires.
Type Parameters
K
K extends OpenRVEventName
Parameters
event
K
The event name to listen for (see OpenRVEventName).
callback
EventCallback<OpenRVEventData[K]>
Handler function receiving the event-specific data payload.
Returns
An idempotent unsubscribe function. Call it to stop listening.
():
void
Returns
void
Throws
If event is not a valid event name or callback is not a function.
Example
const unsub = openrv.events.on('frameChange', (d) => console.log(d.frame));
unsub(); // stop listeningonce()
once<
K>(event,callback): () =>void
Defined in: api/EventsAPI.ts:139
Subscribe to an event, firing the callback only once then automatically unsubscribing.
Type Parameters
K
K extends OpenRVEventName
Parameters
event
K
The event name to listen for.
callback
EventCallback<OpenRVEventData[K]>
Handler function invoked once with the event data.
Returns
An unsubscribe function (can be called early to cancel before it fires).
():
void
Returns
void
Throws
If event is not a valid event name or callback is not a function.
Example
openrv.events.once('sourceLoaded', (d) => console.log(d.name));