ExamGecko
Question list
Search
Search

Question 4 - Certified B2B Commerce Developer discussion

Report
Export

How can a developer establish communication between components that are not in the same DOM (Document Object Model) tree?

A.
Use publish-subscribe pattern.
Answers
A.
Use publish-subscribe pattern.
B.
Configure targets property.
Answers
B.
Configure targets property.
C.
Use dispatch events.
Answers
C.
Use dispatch events.
D.
Use @api decorators.
Answers
D.
Use @api decorators.
Suggested answer: A

Explanation:

To establish communication between components that are not in the same DOM (Document Object Model) tree, a developer can use the publish-subscribe pattern. The publish-subscribe pattern is a messaging pattern that allows components to communicate with each other without being directly connected or aware of each other. The components can publish events to a common channel and subscribe to events from that channel. The channel acts as a mediator that delivers the events to the subscribers. The developer can use a custom library or a Salesforce platform service, such as Lightning Message Service or Platform Events, to implement the publish-subscribe pattern. Configuring the targets property is not a way to communicate between components that are not in the same DOM tree, as it only defines where a component can be used in an app. Using dispatch events is not a way either, as it only works for components that are in the same DOM tree or have a parent-child relationship. Using @api decorators is not a way either, as it only exposes public properties or methods of a component to other components that use it. Salesforce

Reference:Lightning Web Components Developer Guide: Communicate Across Salesforce UI Technologies,Lightning Web Components Developer Guide: Communicate with Events, [Lightning Web Components Developer Guide: Communicate with Properties]

asked 23/09/2024
Jorge Andres Gutierrez
30 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first