0

I have a value in LWC that needs to be passed to its parent Aura to launch a pre-existing flow. I have seen suggestions to use dispatchEvent, but I am not dealing with any events. It just needs the value to pass from from LWC to Aura so it could launch a flow in JavaScript. What is a best way to this?

1 Answer 1

2

There are only two ways a parent can get changed data from a child component.

Option 1 is to repeatedly check the child to see if the data has changed. This is called polling, and is highly inefficient, which is why we don't frequently use this in modern programming and technology; it consumes resources unnecessarily and can even make apps unresponsive if done poorly.

Option 2 is to set up an event handler and listen for changes. This is maximally efficient, as the listener is idle until it has something to do. This is called event-driven programming, and is the preferred way to write code, as no extra CPU cycles are wasted when there's nothing to do.

As such, you should use dispatchEvent in order to let the parent know when the child value has changed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .