PDI · Question #157
Since Aura application events follow the traditional publish-subscribe model, which method is used to fire an event?
The correct answer is C. fire(). In the Aura component framework, events are published to notify listeners by calling the fire() method on the event instance.
Question
Since Aura application events follow the traditional publish-subscribe model, which method is used to fire an event?
Options
- Aernit()
- BfireEvent()
- Cfire()
- DregisterEvent()
How the community answered
(20 responses)- B5% (1)
- C90% (18)
- D5% (1)
Why each option
In the Aura component framework, events are published to notify listeners by calling the `fire()` method on the event instance.
`ernit()` is not a standard or recognized method for firing events in the Aura component framework.
`fireEvent()` is not the correct method name for firing events in Aura; the correct method is `fire()`.
When an Aura component needs to broadcast an event, it first obtains an instance of the event using `$A.get('e.namespace:eventName')` and then invokes the `fire()` method on that event instance to publish it, triggering any registered event handlers.
`registerEvent()` is used by a component to declare its ability to fire a specific event, not to actually fire the event itself.
Concept tested: Firing Aura application events.
Source: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_application_fire.htm
Topics
Community Discussion
No community discussion yet for this question.