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

Generic version of DOMEvent #4

Open
twitwi opened this issue Nov 2, 2013 · 2 comments
Open

Generic version of DOMEvent #4

twitwi opened this issue Nov 2, 2013 · 2 comments

Comments

@twitwi
Copy link
Contributor

twitwi commented Nov 2, 2013

This is not an issue but rather a feature discussion.

Very often, listener receive a DOMEvent and in a typical javascript application, we would use e.target to get the target of the event and do things with it. I was thinking that DOMEvent could be made generic, as in DOMEvent<TargetType> to avoid needing casts when using e.target.
This, however, has impact on a big part of the API so I don't know if it is a good solution.

@acraciun
Copy link
Member

acraciun commented Nov 3, 2013

I believe target is always at least an element:
But there are two other fields for targets relatedTarget and currentTarget. Not sure if they should be of the same type.

By doing TargetType extends ... existing code will not be broken. They'll only get a warning.

Another thing to consider is that maybe Element should receive the target type as generic parameter too so that all the event handlers will have it.

@twitwi
Copy link
Contributor Author

twitwi commented Nov 4, 2013

I also think it would not break existing code. One of my concerns is that the types would get more verbose (and it will propagate to all handlers too). Also, as you mentioned, relatedTarget and currentTarget could also be templated (probably with independent types) but we then get very very verbose code...

Templating only "target" looked very convenient at first for me, but it is also quite arbitrary (why this one and not others, ...). I don't know :) Maybe we could have a templated version of the bridge and see which one is easier to use.

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

No branches or pull requests

2 participants