Skip to content
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

Closed
wants to merge 6 commits into from
Closed

Enhanced EventEmitter to pass data with an event. fixes #1979 #2163

wants to merge 6 commits into from

Conversation

carpasse
Copy link
Contributor

Extended trigger function to pass the data to the event handlers

@gkatsev
Copy link
Member

gkatsev commented May 18, 2015

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));
Copy link
Member

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);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as below.

Copy link
Member

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.

Copy link
Contributor Author

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).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkatsev , @heff, Would it make sense to enforce the use of a data hash on Events.trigger as I did on component.trigger??

Copy link
Member

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.

@carpasse
Copy link
Contributor Author

@heff My bad. I did miss one 'rest' argument in the 'on' method dispatcher. It should be fixed now.

@heff
Copy link
Member

heff commented May 22, 2015

No worries. Looks good to me. I'll merge in soon.

@heff heff closed this in 55a391b Jun 5, 2015
@heff
Copy link
Member

heff commented Jun 5, 2015

Finally got this merged in. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants