Skip to main content

listenFor

listenFor(messageName, *bundleName, handlerFunc)

Listens for a message, and invokes the provided callback each time the message is received. If any data was sent with the message, it will be passed to the callback.

Messages are namespaced by bundle. To listen to a message in another bundle's namespace, provide it as the second argument.

You may define multiple listenFor handlers for a given message. They will be called in the order they were registered.

Parameters

NameTypeAttributesDefaultDescription
messageNamestringThe name of the message.
bundleNamestring<optional>Current bundleThe bundle namespace to in which to listen for this message.
handlerFuncfunctionThe callback fired when this message is received.