Play with Events in Lightning Component – Part 1

Events plays very important role while developing the Lightning component and communicating between the components.

Introduction :-

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.

In the Lightning Component framework, events are fired from JavaScript controller/helper actions. Events can contain attributes that can be set before the event is fired and read when the event is handled.

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s