Events plays very important role while developing the Lightning component and communicating between the components.
The Lightning framework uses event-driven programming. You write handlers that respond to interface events as they occur. The events may or may not have been triggered by user interaction.
There are two types: component or application.
- 1- Component Events
- A component event is fired from an instance of a component. A component event can be handled by the component that fired the event or by a component in the containment(Upper level) hierarchy that receives the event.
- 2 – Application Events
- 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.
Main difference between application and component event is that Component event can only be handled by parent component and application event can be handled in all over the application.
Component Event needs to be register and handled wherever application event only need to handle and do not need to register.
In next post we will see how Component Event works and when to use component events while developing the custom lightning component.