on

View as Markdown
  • on(event, fn)

Attaches an event handler to the specified event.

Parameters

NameTypeDescription
eventstringName of the event. See the list of events.
fnFunctionAn event handler.

Example

In the below example, we are listening for the call.state event and logging the current call state to the console. This means this will be triggered every time the call state changes.

1call.on("call.state", (call) => {
2 console.log("call state changed:", call.state);
3});