Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Fire Application Events
Register an Event
A component registers that it may fire an application event by using <aura:registerEvent> in its markup. The name attribute is required but not used for application events. The name attribute is only relevant for component events. This example uses name="appEvent" but the value isn’t used anywhere.
1<aura:registerEvent name="appEvent" type="c:appEvent"/>Fire an Event
Use $A.get("e.myNamespace:myAppEvent") in JavaScript to get an instance of the myAppEvent event in the myNamespace namespace.
Use fire() to fire the event.
1var appEvent = $A.get("e.c:appEvent");
2// Optional: set some data for the event (also known as event shape)
3// A parameter’s name must match the name attribute
4// of one of the event’s <aura:attribute> tags
5//appEvent.setParams({ "myParam" : myValue });
6appEvent.fire();Events Fired on App Rendering
Some events are automatically fired when an app is rendering. For more information, see Events Fired During the Rendering Lifecycle.