Skip to main content
3 of 3
edited title
Uwe Heim
  • 28.6k
  • 25
  • 124
  • 295

How to declare aura:handler properly? (Application Event vs. Component Event)

In my test project I'm trying to subscribe on Save Event using. Currently I'm using force:refreshView event to dispatch changes to my custom lightning component. I use this line and all works perfectly.

<aura:handler event="force:refreshView" action="{!c.doInit}" /> 

But after that I tried to subscribe on force:recordSaveSuccess using similar syntax

<aura:handler event="force:recordSaveSuccess" action="{!c.handleSaveSuccess}"/> 

But Developer Console doesn't allow to save and execute this script and Display an error

Failed to save undefined: A aura:handler that specifies an event="" attribute must handle an application event. Either change the aura:event to have type="APPLICATION" or alternately change the aura:handler to specify a name="" attribute.: Source

That literally mean that I need to add name attribute to this handler.

Could anyone explain why I can use force:refreshView without name attribute, but I have to add this attribute for force:recordSaveSuccess? I didn't find anything valuable in SF Lightning doc.