Event in Salesforce

Guide To Component Event And Application Event in Salesforce

Component Event

Component event is fired by the when we instantiate the component. The component is fired from the child component and handled by the Parent component.

A segment occasion is terminated from a case of a segment. A part occasion can be dealt with by the segment that terminated the occasion or by a segment in the regulation progressive system that gets the occasion.

Component Event Propagation

The system underpins catch and air pocket stages for the proliferation of part occasions. These stages are like DOM taking care of examples and giving a chance to intrigued parts to connect with an occasion and conceivably control the conduct for resulting handlers.

Custom Component Event

Make a custom segment occasion utilizing the <aura:event> tag in an .evt asset. Occasions can contain traits that can be set before the occasion is terminated and perused when the occasion is taken care of.

dont miss out iconDon't forget to check out: Salesforce Lightning Web Components: The new way of creating robust components for modern browsers

Fire Component Events

Fire a part occasion to convey information to another segment. A part occasion can be taken care of by the segment that terminated the occasion or by a segment in the control chain of importance that gets the occasion.

Handling Component Events

A part occasion can be dealt with by the segment that terminated the occasion or by a segment in the control chain of command that gets the occasion.

Aura:Method

Empowers you to legitimately call a strategy in a part's customer side controller as opposed to terminating and dealing with a segment occasion. Utilizing <aura:method> rearranges the code required for a parent segment to consider a technique on a youngster segment that it contains. 

The <aura:method> tag has these framework traits.

Example:

<aura:method name="sample" action="{!c.doWork}" 
  description="Sample  with parameters"> 
    <aura:attribute name="p1" type="String" default="parameter 1"/> 
    <aura:attribute name="p2" type="Object" /> 
</aura:method>

Handler Action

({
    doWork : function(cmp, event) {
        var params = event.getParam('arguments');
        if (params) {
            var p1 = params.p1;
            // add your code here
        }
    }
})

Returning Value

aura:method executes simultaneously. 

A coordinated technique completes the process of executing before it returns. Utilize the arrival articulation to restore an incentive from the simultaneous JavaScript code. See Return Result for Synchronous Code

An offbeat technique may keep on executing after it returns. Utilize a callback to restore an incentive from offbeat JavaScript code. See Return Result for Asynchronous Code.

dont miss out iconCheck out another amazing blog by Marziya here: Schedular Class in Salesforce | Apex Developer Guide

Application Event

Application occasions follow a customary distribute buy-in model. An application occasion is terminated from a case of a part. All parts that give a handler to the occasion are told. The structure underpins catch, air pocket, and default stages for the proliferation of utilization occasions. The catch and air pocket stages are like DOM taking care of examples and giving a chance to intrigued parts to communicate with an occasion and conceivably control the conduct for resulting handlers. The default stage saves the system's unique taking care of conduct.

The structure bolsters catch, air pocket, and default stages for the engendering of utilization occasions. The catch and air pocket stages are like DOM dealing with designs and give a chance to intrigued segments to interface with an occasion and conceivably control the conduct for resulting handlers. The default stage safeguards the structure's unique dealing with conduct.

Thank You!

Responses

Popular Salesforce Blogs