You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just started learning Stimulus’s cross-controller event system, and while its functionality is neat, I'm curious how others are solving some basic scenarios I expected to work out of the box. Just as a trivial example, assume the controllers are totally separate and the buttons dispatch their own custom button:click events
Scenario 1: Global Listening
In this example, the dialog listens for any dispatched button:click events and opens accordingly. This works great, but has limited use cases for me
I expected to be able to filter events by the event.target so that the dialog only reacts when a specific button (e.g., #button-1) is clicked. However, this is not possible
Is everyone simply writing additional controllers every time some controllers need to interact?
Any insights or alternative patterns would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey all,
I've just started learning Stimulus’s cross-controller event system, and while its functionality is neat, I'm curious how others are solving some basic scenarios I expected to work out of the box. Just as a trivial example, assume the controllers are totally separate and the buttons dispatch their own custom button:click events
Scenario 1: Global Listening
In this example, the dialog listens for any dispatched button:click events and opens accordingly. This works great, but has limited use cases for me
Scenario 2: Filtering by Specific Selector
I expected to be able to filter events by the event.target so that the dialog only reacts when a specific button (e.g., #button-1) is clicked. However, this is not possible
Similarly, it would be nice to be able to use any selector to listen for arbitrary events
Scenario 3: Calling an Action on a Specific controller
It would be amazing to call an action on an external controller. For example, this button could trigger the dialog’s open method directly.
Is everyone simply writing additional controllers every time some controllers need to interact?
Any insights or alternative patterns would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions