-
Notifications
You must be signed in to change notification settings - Fork 110
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
Normalize handler signature #80
Comments
@ryanve I completely agree with you here, and not just for jQuery compatibility, the Consider this jQuery, a pattern used a bit in Bootstrap: var e = $.Event('show')
el.trigger(e)
if (!e.isDefaultPrevented()) {
// do something
} Being able to create and retain the event object has a heap of benefits. Unfortunately the horse has bolted on that and it's a bit difficult to change the API. Perhaps we'll try and solicit some feedback on this to see if anyone is actually using the trigger arguments in Bean. |
@ded @connor @st-luke @iamdustan (or anyone else?) got an opinion on this? |
I'm not using trigger args in bean but normalization is a good thing if it can be done without totally screwing people. |
I'm also not using trigger arguments in any projects using Bean (although may discover some during the conversion, Rod, like we talked about over email). I'm for the first element in the array being reserved for an |
I agree with the argument presented here that the first argument should be reserved for the eventData object and the second being optional arguments. It’s clean and provides an expected and consistent way to determine how the event was triggered and how to access your custom arguments. I haven’t used the trigger arguments because of how it’s applied currently (I tried. I may still have used it, but it definitely caused some confusion at the time) |
To improve jQuery-compatibility and general consistency in the arguments passed to event handlers via different methods, I think that
bean.fire()
and.trigger()
need modification. Consider:The arguments passed to handlers should be as normalized as possible between native / custom / triggers etc. The
arguments[0]
slot should be reserved for an eventData object. In situations without applicable eventData, it could be passed asnull
or (better) a simple object like:The text was updated successfully, but these errors were encountered: