[LiveComponent] Emitting Event to specific instance #2916
Replies: 7 comments
-
It is not possible no, but they maybe can "do" something if they match the id of the event ? |
Beta Was this translation helpful? Give feedback.
-
Yes, bud this is trigered reload all 10 instances and i want avoid it because render this component is heavy. Maybe not heavy, but now I have 60 instances on page, Ind i need reload only one. |
Beta Was this translation helpful? Give feedback.
-
As Event are really just "strings", did you try to emit something like "foo_42" where 42 is the id in question, and listen to this event in your component 42 ? |
Beta Was this translation helpful? Give feedback.
-
Im still not understand what you mean..
I can't add id to listener name like |
Beta Was this translation helpful? Give feedback.
-
So there is nothing like that in LiveComponent sorry. The compote works around events, delegation or "in-scope" actions. |
Beta Was this translation helpful? Give feedback.
-
Depending on "who" emit the initial event you're talking about... ... you could listen on front-end with a custom stimulus controller on your component instances, where you would check the "id" and then dispatch a "emitSelf" event. Is this the same scenario that the other issue ? |
Beta Was this translation helpful? Give feedback.
-
Yesm this custom stimulus controller is good enough for me. thanks |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have 10 instances of same component in page with live prop $id. I want emit event to only one instacne of this component with specific $id.
Is something like this possible?
Beta Was this translation helpful? Give feedback.
All reactions