Component events, propagation and Lightning Message Service
Pick the communication channel from where two components sit: @api and aura:method calls down, LWC custom events and Aura component events up, Lightning Message Service or Aura application events across. Covers propagation flags, retargeting, message scope, owner versus container handling and LWC events caught by an Aura parent.
Given a scenario, implement the correct method to communicate events through Lightning Web Components or Aura Components.
~8 min read · 11 practice questions ·
What the exam expects
- Choose between an
@apimethod, a custom event and Lightning Message Service (oraura:method, a component or an application event) from where the components sit. - Pick the most restrictive
bubbles/composedconfiguration that reaches a given listener, and explainevent.targetretargeting. - Subscribe to a message channel with the right context and scope.
- Fix Aura code that fires or handles a component or application event with the wrong syntax, or expects a container to handle an event.
- Handle a Lightning web component's event in an enclosing Aura component.
Key terms: owner (the outermost component whose markup declares a component), container (a component that renders others through a facet such as {!v.body} without owning them), retargeting (changing event.target to an element in the listener's scope), message channel (the LightningMessageChannel Lightning Message Service publishes on).
Key facts
- Detail
bubbles: false,composed: false
- Detail
- Bubbling only; capture isn't supported
detail- Detail
- Copy to a new object first, or listeners can mutate it
- Detail
- Part of the public API; namespace the type
- Detail
- Active area only; utility items are always active
- Detail
{ scope: APPLICATION_SCOPE }assubscribe()'s fourth argument
pubsub module- Detail
- Not officially supported; only where LMS isn't
- Detail
cmp.getEvent("registeredName")thenfire()
- Detail
- Add
includeFacets="true"to the container's handler
- Detail
- No
nameattribute
aura:method- Detail
- Parent calls the child's method directly; runs synchronously
Sources for this section (8)
- Configure Event Propagationdeveloper.salesforce.com (opens in a new tab)
- Create and Dispatch Eventsdeveloper.salesforce.com (opens in a new tab)
- Define the Scope of the Message Servicedeveloper.salesforce.com (opens in a new tab)
- Communicate Across the DOMdeveloper.salesforce.com (opens in a new tab)
- Fire Component Eventsdeveloper.salesforce.com (opens in a new tab)
- Handling Bubbled or Captured Component Eventsdeveloper.salesforce.com (opens in a new tab)
- Handling Application Eventsdeveloper.salesforce.com (opens in a new tab)
- aura:methoddeveloper.salesforce.com (opens in a new tab)
- Why is `bubbles: true, composed: true` discouraged for a reusable component's event?
- When does a Lightning Message Service subscriber need `APPLICATION_SCOPE`?
- Why doesn't a container that renders a child through `{!v.body}` handle the child's component event by default?
- Which call gets an application event instance, and which gets a component event?
- When does `event.target` differ from the element that dispatched an LWC event?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Developer II pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 28 lessons of the Platform Developer II guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (11 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams