-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement core events for common actions #288
Conversation
Just thinking out loud here, is there a going to be a noticeable overhead in emitting events on every mutation? |
From my testing, the overhead is minimal. Of course, the overhead will grow with the number of event listeners that need to run on each mutation / update, but that is really down to the developer to manage. Still a very good point though and might be worth adding to the docs as a warning. It does take the gzipped bundle size over 7kb, but I think that there are a few other places in the code that we can tidy up too that will help with that. P.s. ignore all of these commits, I'm going to squash them :) |
Another addition could be: |
I somewhat agree with you. The It will also remove the need for using conditionals in your The |
I do like the idea of having events 👍 even if it may seem similar to
|
|
Accidentally clicked close 🤦🏻♂️. Yeah, the If the events were to be more specific, I would prefer to place the context after |
Better 👍 Regarding |
I'd say it's better to give the developer both options. Switch statements can get ugly too, I don't like them. |
Gonna close this PR and open a more formal one. |
Here is my initial PR for implementing core events for common actions in Alpine. It closes #283 . There's room for improvement here still, but this is the initial PR to get some feedback and suggestions for some more events, etc.
These are the events that are getting fired currently.
alpine:loaded
- fired at document level after Alpine has initialised all components.alpine:mutated
- fired at component level on the parent element when a piece of data is mutatedalpine:[key]-mutated
- fired at component level on the parent element when thekey
data has been mutatedalpine:updated
- fired at component level on the parent element when the component has been updated / refreshed.alpine:transition-start
- fired at transitioning element level but will bubble up so event listener can be attached to parent component too, will fire when the transition startsalpine:transition-end
- fired at transitioning element level but will bubble up so event listener can be attached to parent component too, will fire when the transition endsTo-do:
cc/ @calebporzio @SimoTod @HugoDF