[SalesForce] 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.

Best Answer

In general component event requires name attribute to be defined in the aura:handler. See the handling of component event for more info.

Look at the doc on force:recordSaveSuccess it pretty much clear that it is an component event, which is why it's handler without name defined threw an error.