Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt

Use this file to discover all available pages before exploring further.

Removes a subscription to an event type. The specified handler will no longer be called when the event occurs.

Syntax

instance.off(eventName, handler);

Parameters

eventName
required
The name of the event to unsubscribe from.
handler
function
required
The specific callback function to remove. Must be the same function reference that was used with on() or once().

Returns

void
Returns a void operator.

Examples

The following examples show different ways to unsubscribe from events:
// Define a handler
function receiveHandler(event, instance) {
    console.log('Message received:', event);
}

// Subscribe to event
instance.on('receive', receiveHandler);

// Later, unsubscribe from event
instance.off('receive', receiveHandler);

// Unsubscribe after first use
instance.on('receive', (event, instance) => {
    console.log('Received:', event);
    instance.off('receive', receiveHandler);
});

Do you need practical examples?

Learn how to apply the features available for embedded chat into your implementation with guidance and examples.