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

Pass event object to custom event handlers #47

Merged
merged 1 commit into from
Nov 27, 2018

Conversation

agrif
Copy link
Contributor

@agrif agrif commented Nov 24, 2018

Followup to Issue #44.

A quick guide to changes:

  • Added "Event" feature to web-sys dependencies for virtual-dom-rs and and virtual-node.
  • Modified CustomEvents and the html! macro to accept FnMut(Event) -> ().
  • Copy/pasted the oninput test, but this time using the generic handler syntax.
  • Changed all the examples I could find to accept an event object (named _ev, usually). I may have missed some.

I didn't touch the versions, though this is a breaking change. I dunno how you handle that.

Something I didn't anticipate: even without casting the Event to something more specific, this gives the handler immediate access to the element it's tied to, which is a pretty big win by itself.

@vercel
Copy link

vercel bot commented Nov 24, 2018

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Copy link
Owner

@chinedufn chinedufn left a comment

Choose a reason for hiding this comment

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

Awesome!!!!! So a huge win. I'm almost thinking that we should favor this over adding all of the other events in.. Can't think of a reason that we wouldn't just recommend that people do their events this way.

@chinedufn
Copy link
Owner

I'll get this merged and deployed later tonight.

To answer your question above -> Until we hit 1.0 we're making breaking changes as minor bumps.

@chinedufn chinedufn merged commit b8092ca into chinedufn:master Nov 27, 2018
@chinedufn
Copy link
Owner

@agrif agrif deleted the generic-event-passing branch November 27, 2018 11:58
@agrif
Copy link
Contributor Author

agrif commented Nov 27, 2018

Awesome.

I'll go and update my stuff!

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

Successfully merging this pull request may close these issues.

2 participants