Closed patricklehmann closed 5 years ago
Hey @patricklehmann, The current behaviour is intentionally implemented like that. Events only bubble up the DOM tree (as also native events do).
For your example, the proper way would be to implement a public method in your child component, which set's the States class.
You can then use this public method in your parent component by using the gondel core function findComponents
to get the instance of your child component to call the public methd
@janwidmer i'll give it a try and reply to you!
@patricklehmann you can find detailed example about the functionality here: https://gondel.js.org/docs/communication.html
The event feature is only intended to be used when you don't have a handle on the dom node of that component AND it is a parent of the current component.
I use it mostly to to things on my page controller component, e.g. enabling / disabling scrolling.. Most cases can and should be handled by calling public methods on the components.
@janwidmer great! That's a working solution. It this "the way to go with gondel"? Thanks for your fast reply.
@patricklehmann yes, working with public method's to communicate is the way to go with gondel in most cases. It should lead to a more strict interaction of components..
Type of issue
Bug report
"@gondel/core": "0.1.0", "@gondel/plugin-hot": "0.1.0",
Expected behavior
When i click on a button within the parent component the public event is triggered on the child components as well.
Current behavior
A event triggered by triggerPublicEvent on a parent component won't be triggered on a child component.
Steps to reproduce the behavior