Activity › Forums › Salesforce® Discussions › When should we use Component event and application events?
Tagged: Application Event, Component Event, Hierarchy, Lightning Framework, Salesforce Javascript Controller, Salesforce Lightning
-
When should we use Component event and application events?
Posted by Aman on September 23, 2018 at 10:43 PMWhen should we use Component event and application events?
Parul replied 7 years, 8 months ago 3 Members · 2 Replies -
2 Replies
-
It is best to always use a component event instead of an application event. Component events can only be handled by components above them in the containment hierarchy, therefore, their usage is localized to the components that need to know about them.
Application events are best used for something that should be handled at the application level, such as navigating to a specific record. Application events allow communication between components that are in separate parts of the application and have no direct containment relationship.
- [adinserter block='9']
-
Addin some more points:
Application Events vs Component Events : Which/How to use for handling custom events in Lightning. Lightning framework is based on event-driven architecture which allows to communicate between different events. Lightning events can be fired or handled by javascript controller.
Log In to reply.