Events strategy for performance and ease of code maintenance
Application events can take significant performance. Hence, it is recommended that if you need to communicate between two components that follow a hierarchy and there is no business need to couple the components loosely, use a component event instead of an application event.
Also, as a rule of best practice, use only one component event throughout the application. For additional details, refer to the Advanced Event Architecture section in Chapter 5, Events in the Lightning Component Framework.
Event anti-patters that can cause a performance bottleneck
Do not fire an event in the renderer. This can cause an infinite loop. The following code shows the anti-pattern that should be avoided:
afterRender: function(cmp, helper) { this.superAfterRender(); $A.get("e.myns:mycmp").fire();//This is an Anti pattern }
Note
You can't use different actions for onclick
and ontouchend
events in a component. The framework translates touch-tap events...