System Events

System Events in Salesforce - Learn All About it Here

The Lightning framework fires system events automatically during component initialization, attribute value changes, rendering, and so on. In their HTML markup, all Components can register for system events. 

These events can be handled in Lightning apps or components, as well as the Salesforce mobile app. A few instances of system events are  listed below. 

Events Name

1. aura:doneRendering

The aura:doneRendering event is no longer supported. Instead, use the render event. The container app may trigger your event handler numerous times unless your component is running in total isolation in a standalone app and not included in complicated apps like Lightning Experience or the Salesforce mobile app. This conduct makes it tough to respond appropriately to each situation. 

If no further components need to be drawn or rerendered as a result of attribute value changes, this event is automatically fired. 

Take care of the aura: completed 

In a client-side controller, a rendering event occurs. This event can only be handled by one aura:handler> tag per component. 

dont miss out iconDon't forget to check out: Real-Time Event Monitoring in Salesforce

2. Aura: ValueChange Event

In Salesforce's lightning components, the aura:valueChange event is used to manage attribute value changes. 

3. aura:ValueDestroy

When a component is destroyed, this event is triggered. If you need to execute custom cleanup after a component is destroyed, handle this event. 

Assume you're looking at a component in the Salesforce app. When you tap on a different menu item on the Salesforce mobile navigation menu, the aura:valueDestroy event is triggered, and your component is destroyed. The value parameter in the event in this case returns the component that is being destroyed. 

4. aura:ValueInit

Prior to rendering, when an app or component is initialised, this event is fired. Use the aura:handler tag to handle this event. 

System events are simple to manage, and if you wish to apply logic during the occurrence of any of the aforementioned events, you can do so by adding the following code to your HTML markup code: 

<aura:handler name="name of the event" value="!this" action="!c.handleSystemEvent"/> 
<aura:handler name="name of the event" value="!this" action="!c.handleSystemEvent"/> 
<aura:handler name="name of the event" value="!this" action="!c.handleSystemEvent"/>

NB: "name of the event" can be any of the following: init, render, destroy, change, and aura:systemError. 

dont miss out iconCheck out another amazing blog by Arpit here: Visualforce in Lightning Experience | Salesforce Guide

Now you can use the following syntax to write the logic that you wish to run in the JS controller: 

(do your logic) (handleSystemEvent: function (component, event, helper) 

The benefit is that all of these components can be reused. However, one of Javascript's limitations is that one component's JS cannot communicate with another component's JS. 

What is the best way for these components to communicate with one another? This is when the role of Events comes into play. Lightning Events, to put it another way, are the link between these two worlds. This blog discusses the Salesforce Lightning Framework Events, as well as when and when they should be used. 

 

Responses

Popular Salesforce Blogs