How do you handle a component event in lightning?

How do you handle a component event in lightning?

A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event. The name attribute in must match the name attribute in the tag in the component that fires the event.

What is the difference between lightning component and lightning application?

Lightning components provide a modern framework for building single-page applications with dynamic, responsive user interfaces for Force.com apps. Lightning components are small reusable applications that can be used in lightning pages. They are developed using apex and aura. It requires coding knowledge.

When do we use application events in Lightning?

To know more about event handling order and propagation of events in lightning refer to Event propagation. Application events are used when you need two independent component to communicate with each other i.e. they don’t need to be in the component hierarchy or nested within each other.

How does Lightning Aura Framework handle application events?

The framework supports capture, bubble, and default phases for the propagation of application events. The capture and bubble phases are similar to DOM handling patterns and provide an opportunity for interested components to interact with an event and potentially control the behavior for subsequent handlers.

What happens when an event is fired in an application?

Event fired —An application event is fired. The component that fires the event is known as the source component. Capture phase —The framework executes the capture phase from the application root to the source component until all components are traversed. Any handling event can stop propagation by calling stopPropagation () on the event.

Where are lightning events fired in JavaScript?

Lightning events are fired from JavaScript controller actions that are triggered by a user interacting with the user interface. The communication between components are handled by events.