-
Notifications
You must be signed in to change notification settings - Fork 49
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stimulus action @window
or @document
equilvalent?
#311
Comments
We wanted to avoid global event listeners as we find they do more harm than good, for the most part. There seems to be two classes of global event listeners:
There's some validity to events that hang directly off of I'll close this issue as hopefully this explains the justification for avoiding these shorthands. If you want to discuss it further though, let's do so! |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I noticed in the guides as well as the
bind.ts
tests that one cannot register actions to listen to global events.What's the
catalyst
way of solving this?For example, one may want to listen for a
scroll
event in the global scope, or a global event from a library like Turbo, such asturbo:before-visit@window
to persist state changes between HTML pages that have the same custom element. I also use it to register window keybindings for when the custom element will not be in focus.One could very well register it within the custom element with
window.addEventListener
-- but one of the main things attractive about Stimulus is that it handles event registration and destruction for youAre there plans to support this, or if not, what is your suggested strategy for dealing with event listeners on the global scope?
The text was updated successfully, but these errors were encountered: