How are application events fired in Lightning aura?

How are application events fired in Lightning aura?

Application events follow a traditional publish-subscribe model. An application event is fired from an instance of a component. All components that provide a handler for the event are notified.

How to handle an application event in aura?

The aeHandler.cmp handler component uses the tag to register that it handles the application event. The handler for an application event won’t work if you set the name attribute in . Use the name attribute only when you’re handling component events.

How to add bubble handler in Lightning aura?

To add a handler for the bubble phase, set phase=”bubble”. The event attribute specifies the event being handled. The format is namespace:eventName. The action attribute of sets the client-side controller action to handle the event. To add a handler for the capture phase, set phase=”capture”.

Is the name attribute required for application events?

The name attribute is required but not used for application events. The name attribute is only relevant for component events. The button in the component contains a onclick browser event that is wired to the fireApplicationEvent action in the client-side controller.

How is an application event used to update an attribute?

Here’s a simple use case of using an application event to update an attribute in another component. A user clicks a button in the notifier component, aeNotifier.cmp. The client-side controller for aeNotifier.cmp sets a message in a component event and fires the event.

How to stop an application event from propagating to?

During the event bubble phase, use event.stopPropagation () to cause the component’s root to be become the root node for the default phase. This means you’ll need a handler at the top-level component to halt propagation beyond that component. See Application Event Propagation. It’ll stop processing with the component that fired the event.

How are application events handled in Salesforce framework?

Application events follow a traditional publish-subscribe model. An application event is fired from an instance of a component. All components that provide a handler for the event are notified. The framework supports capture, bubble, and default phases for the propagation of application events.