Skip to content

eventBus.getListeners

The getListeners method allows to get all listeners of given message.

Input parameters

messageName

messageName is a mandatory parameter of the string type which represents the name of the message to get the listeners from.

Returned value

A returned value has a type of TMessageListener[] where TMessageListener represents the TMessageListener type

Example

To get all listeners for a given message using the Event Bus you can use the getListeners method:

useStorefront(async (storefront) => {
    const listeners = storefront.eventBus.getListeners('my-event');

    console.log('listeners of my-event:');

    listeners.forEach((listener) => {
        console.log('listener:', listener)
    })
});

Methods reference