Skip to content

eventBus.getListenersCount

The getListenersCount method allows to get the count of 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 count from.

Returned value

A returned value has a type of number representing a number of listeners for the given event.

Example

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

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

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

Methods reference