Replies: 2 comments 1 reply
-
Are we talking sibling components interested in what each other are firing? If it's parents/children/[great*-]grandchildren, the official preferred method would be to proxy the child events e.g. I have a handful of components that I just want to grab something like the I have used a detached ractive instance as an event bus before, but it really depends on the situation how you would hook that up. You can expose the bus in the data or import it and use method listeners to call it in the instance code. So something like Again, it really depends on the situation, but some combination of those usually has me covered. I've also used the same global instance pattern for shared data, where data is mostly stored in a detached global instance and linked into whatever components need it. That often lets me skirt the need for additional events by sharing observers. |
Beta Was this translation helpful? Give feedback.
-
Ractive events bubble up the component hierarchy to their root, so not really globally. When the event bubbles across its origin component boundary, it gets namespaced with that component name. So |
Beta Was this translation helpful? Give feedback.
-
Hi, what is the prefered way of listening to events of a component within a component ?
Currently I always fire the event and listen on root, try to find the component which is actually interested in and push data to the interface.
But actually I would like to fire the event only to the "Hosting " component ... like a component with any button click within a global component.
Do not wanna mess up root instance ...
Any suggestions welcome!
Beta Was this translation helpful? Give feedback.
All reactions