Newer Version Available

This content describes an older version of this product. View Latest

Fire Application Events

Application events follow a traditional publish-subscribe model. An application event is fired from an instance of a component. All components that provide a handler for the event are notified.

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.

Fire an Event

Use $A.get("e.myNamespace:myAppEvent") in JavaScript to get an instance of the myAppEvent event in the myNamespace namespace.

The syntax to get an instance of an application event is different than the syntax to get a component event, which is cmp.getEvent("evtName").

Note

Use fire() to fire the event.

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.