Activity › Forums › Salesforce® Discussions › When we should use aura:handler in Salesforce lightning component ?
Tagged: Aura Handlers, Client Side Controller, Custom Event, Custom Lightning Event, Lightning Events, Salesforce Lightning Component
-
When we should use aura:handler in Salesforce lightning component ?
Posted by Nikita on December 3, 2019 at 5:06 PMWhen we should use aura:handler in lightning component ?
Piyush replied 6 years, 5 months ago 2 Members · 1 Reply -
1 Reply
-
Hi,
In lightning component <aura:handler… > is used for handle standard and custom events
we can create our custom lightning event and also use standard events, standard lightning event is automatically fired when related event is fire
standard event like -:
1. aura:valueInit – : Indicates that an app or component has been initialized.
This event is automatically fired when an app or component is initialized, prior to rendering. The aura:valueInit event is handled by a client-side controller. A component can have only one <aura:handler name=”init”> tag to handle this event.Ex:-
<aura:handler name=”init” value=”{!this}” action=”{!c.doInit}”/>2.aura:waiting -: Indicates that the app or component is waiting for a response to a server request. This event is fired before aura:doneWaiting.
This event is automatically fired when a server-side action is added using $A.enqueueAction() and subsequently run, or when it’s expecting a response from an Apex controller. The aura:waiting event is handled by a client-side controller. A component can have only one <aura:handler event=”aura:waiting”> tag to handle this event.Ex:-
<aura:handler event=”aura:waiting” action=”{!c.showSpinner}”/>3. aura:doneWaiting – : Indicates that the app or component is done waiting for a response to a server request. This event is preceded by an aura:waiting event. This event is fired after aura:waiting.
This event is automatically fired if no more response from the server is expected. The aura:doneWaiting event is handled by a client-side controller. A component can have only one <aura:handler event=”aura:doneWaiting”> tag to handle this event.
Ex:-
<aura:handler event=”aura:doneWaiting” action=”{!c.hideSpinner}”/>
Log In to reply.