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

Rename .on()? #7

Closed
shama opened this issue May 13, 2015 · 7 comments
Closed

Rename .on()? #7

shama opened this issue May 13, 2015 · 7 comments
Labels

Comments

@shama
Copy link
Owner

shama commented May 13, 2015

Originally I named it .on() for readability, such as el.on('click') or el.on('selected'). But I understand that is a commonly used name so maybe another would be better suited. Initiated by this: https://twitter.com/yoshuawuyts/status/597563041119608832

@yoshuawuyts Could you elaborate more on why .attachListener() would be a better name? Thanks!

@shama
Copy link
Owner Author

shama commented Jun 1, 2015

Pinging @yoshuawuyts @bendrucker @sethvincent for an opinion on whether or not .on() should be renamed. I am indifferent. Thanks for the input!

@shama
Copy link
Owner Author

shama commented Jun 1, 2015

Also @Flet, thanks!

@yoshuawuyts
Copy link
Contributor

Oh shoot, forgot to come back on this.

I really like the .on() name to interact with, but as was pointed out to me by other developers it isn't compatible with how other elements in the browser work. Instead we might want to consider EventTarget.addEventListener. This way elements created with base-element can be used with any library that knows how to deal with regular DOM listeners.

There's a (broken) example of how this could be done here using synthetic-dom-events.

I think that would make a reasonable base, at a higher level .on() could be implemented by a system similar to dom-wrap or dom-on.

Does this make sense?

@bendrucker
Copy link
Collaborator

+1 to addEventListener. I think this could be like standard in that teams could publish ${name}-standard or a scoped npm package with the sugar methods they want.

@shama
Copy link
Owner Author

shama commented Jun 1, 2015

Ah interesting, that makes sense. I am also now +1 to addEventListener. Thanks!

@Flet
Copy link

Flet commented Jun 1, 2015

This is sensible!

@shama shama closed this as completed in 85ae684 Jun 1, 2015
@yoshuawuyts
Copy link
Contributor

wooh! 🎉

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

No branches or pull requests

4 participants