aura:valueDestroy

Indicates that a component has been destroyed. Handle this event if you need to do custom cleanup when a component is destroyed.

This event is automatically fired when a component is being destroyed. The aura:valueDestroy event is handled by a client-side controller.

A component can have only one <aura:handler name="destroy"> tag to handle this event.

<aura:handler name="destroy" value="{!this}" action="{!c.handleDestroy}"/>

This client-side controller handles the aura:valueDestroy event.

({
    handleDestroy : function (component, event, helper) {
      var val = event.getParam("value");
      // Do something else here
    }
})

Let’s say that you are viewing a component in Salesforce1. The aura:valueDestroy event is triggered when you tap on a different menu item on the Salesforce1 navigation menu, and your component is destroyed. In this example, the value parameter in the event returns the component that’s being destroyed.

The <aura:handler> tag for the aura:valueDestroy event contains these required attributes.
Attribute Name Type Description
name String The name of the handler, which must be set to destroy.
value Object The value for which you want to detect the event for. The value that is being destroyed. Always set value="{!this}".
action Object The client-side controller action that handles the destroy event.
The aura:valueDestroy event contains these attributes.
Attribute Name Type Description
value String The component being destroyed, which is retrieved via event.getParam("value").