-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Enhanced EventEmitter to pass data with an event. fixes #1979 #2163
Conversation
Awesome stuff. |
@@ -53,7 +53,7 @@ export function on(elem, type, fn){ | |||
if (event.isImmediatePropagationStopped()) { | |||
break; | |||
} else { | |||
handlersCopy[m].call(elem, event); | |||
handlersCopy[m].apply(elem, [event].concat(evtData)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to do something like
handlersCopy[m].call(elem, event, ...evtData);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carpasse did you want to update these to match the single hash arg or are you happy with it as is? Other than this question I think it's good to pull in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heff I did update them 3 days ago. I don't know why they are not shown here.
Can you please take a look a the changes in master...carpasse:feature/event-emitter-enhance
*/ | ||
export function trigger(elem, event) { | ||
export function trigger(elem, event, ...evtData) { | ||
// Fetches element data and a reference to the parent (for bubbling). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense to me.
@heff My bad. I did miss one 'rest' argument in the 'on' method dispatcher. It should be fixed now. |
No worries. Looks good to me. I'll merge in soon. |
Finally got this merged in. Thanks! |
Extended trigger function to pass the data to the event handlers