Skip to main content

api.on()

View Source: on

Usage

api.on(eventName, handler): number;

Description

Attach an event handler to an event.

Sample Code

TypeScript Example:

// Example usage of api.on()
const result = await api.on();
console.log(result);

Parameters

eventName

string

Name of the event to listen for

handler

(...args) => void

Callback function to execute when event fires

Returns

number

Token for later detachment