Activity Forums Salesforce® Discussions When we should use aura:handler in Salesforce lightning component ?

  • Piyush

    Member
    December 4, 2019 at 5:19 am

    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.

Popular Salesforce Blogs

Popular Salesforce Videos