-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
events: add off alias to removeListener #17156
Conversation
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.
Changes LGTM - let's see if we have consensus on adding it.
One note - even if we do get consensus on adding this feature, I think we should give @yosuke-furukawa the option to update the original PR in #540 (referenced in #17102) if they want to do so. |
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.
This will always be desired by anyone coming to Node having done any sort of front-end work... I don't see much harm to adding it.
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.
Agree on preferring the original PR if possible, psyched to see this happen!
Please make sure to CITGM this. |
CI & CITGM seem good. I have to admit I’m surprised by the enthusiasm for this option expressed in the linked issue – this seems like a mediocre name at best, it’s not like you could say “do X off an occasion” in English… |
The use in a sentence isn’t the attraction; it’s more that the obvious answer to the question “how do i undo ‘on’” is “use ‘off’”. This has been a pain point in node for many years as a result; one that has always taken a line of code to address. Looking forward to this landing. |
This has been discussed a lot and there still seem to be a lot of different opinions. I would love to have a very simple vote on this, not with the intention of deriving a decision from it, but because I think that GitHub approvals don't necessarily represent opinions, and I would love to get more feedback on this idea. This is not limited to organization members, but I would be happy about as many votes from @nodejs/collaborators as possible! Before voting, please read #17102 for a summary of the most relevant aspects of this change. Feel free to comment your own point of view or any reasons to or not to create
One aspect which only occurred to me recently is that Please pick at most one of And any combination of (It seems like the heart emoji is not always visible in Firefox, but you should still be able to select it from the list when voting. The emoji is labelled "Heart" when you hover over the empty space.) If you vote 👍 or 👎 for reasons other than those outlined in #17102, feel free to leave a comment to tell us about your reasons! |
I've always felt like on and removeListener were from two different libraries. ideally I think it should have been addListener and removeListener. perhaps both aliases could be added, although that might get a bit confusing. I just see it as a consistency thing, where someone shouldnt have to go to the docs because you can't guess one if you only know the other. |
@devsnek |
@devsnek this would be a different discussion if both aliases were being added; but “on” and “addEventListener” have always been aliases - adding “off” completes the set. |
as node is a beautiful abstraction of low level events and code around those events, this is a wonderful construct that aligns to this philosophy. |
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’m extremely -1 to add a 3 char method to the base of a good chunk of the ecosystem, mainly because of possible conflicts. Unfortunately, I’m away for the next two weeks to better formulate my thoughts.
I’m marking it as “request changes” mainly to make my opinion visible.
Besides the unnecessary clutter, |
Of course it makes it easier. Anyone coming from any front-end work — which Node.js has become a huge part of — will expect I feel like there's just this fundamental clash between developers coming from a different context than the one that had traditionally dominated Node.js usage. Front-end in general is possibly the largest consumer of Node.js so to ignore that perspective is a big mistake. The general unwillingness to try to empathize with a large swath of the user-base which is coming at this with a wholly different context is kind of a major turn-off in these debates. |
I'm curious where else |
I'm puzzled by your argument, and your statement that anybody disagreeing with you lacks empathy, perhaps we can focus on the EventEmitter, not personal accusations? If we don't discuss what APIs make sense based on the actual meaning of English words, what do we discuss? What is it about front-end developers that make them particularly need this when doing back-end development? AFAIK, there is no EventEmitter in the browser. |
Front-end tooling is currently (very likely) the largest consumer of Node.js... this isn't back-end development.
Bringing it back to the language is refusing to empathize with where other users are coming from. I don't have particularly strong feelings on adding |
@tniessen would you consider editing your poll comment to slightly call out #17102 more? I realize that it obviously contains some of my opinions, and would want people to make formulate their own opinion, but I'm also pretty sure that many people are going to just come to this issue, quickly skim it, and start providing their quick opinions without considering the ecosystem as a whole, or any of the past arguments. (As it seems like the comments are already doing.) |
If Or maybe |
Everyone, do you think if an attempt to override it should warn users? Such overriding would mean one of two things:
|
@ChALkeR I think a warning for overriding it with the same However, I don't think either is necessary if it's landing in a semver-major; if we were landing it in a minor (which we're not, based on the current votes in this thread) then I'd hope the second warning you indicated would indeed exist. |
@MylesBorins for me it was not about timing but about having a conclusion. I am aware that this is not time sensitive. |
@ljharb Well, the warning could be trivially disabled for overriding with Also, this is clearly a semver-major because of breakage potential, and I think it would still make sense to enable such warning even in a semver-major change, because otherwise it would be hard to notice problems — people don't generally re-read all the code searching for what changed, especially if the affected code is hidden deep inside dependencies which are not very actively supported. |
I am going to abstain, there is already a majority anyway though. |
+1 from me. |
It looks like the TSC has voted in favor of this PR. CI and CITGM already passed - going to land this tomorrow unless anyone has more questions or comments (or someone will beat me to it) - and @Ulmanb has offered to do a follow-up PR about overriding behavior. |
Landed in 3bb6f07 🎉 |
Add `off` as an alias for `removeListener` PR-URL: #17156 Refs: #17102 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #20291 Refs: #17156 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #20291 Refs: #17156 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
<!-- Have any questions? Check out the contributing docs at https://gatsby.app/contribute, or ask in this Pull Request and a Gatsby maintainer will be happy to help :) --> ## Description <!-- Write a brief description of the changes introduced by this PR --> This fixes a bug introduced in #10593 by replacing the `.off` call with `.removeListener`. `.off` was introduced in Node v10.0.0 as an alias for `.removeListener` (nodejs/node#17156). ## Related Issues <!-- Link to the issue that is fixed by this PR (if there is one) e.g. Fixes #1234, Addresses #1234, Related to #1234, etc. --> Related to #10612
<!-- Have any questions? Check out the contributing docs at https://gatsby.app/contribute, or ask in this Pull Request and a Gatsby maintainer will be happy to help :) --> ## Description <!-- Write a brief description of the changes introduced by this PR --> This fixes a bug introduced in gatsbyjs#10593 by replacing the `.off` call with `.removeListener`. `.off` was introduced in Node v10.0.0 as an alias for `.removeListener` (nodejs/node#17156). ## Related Issues <!-- Link to the issue that is fixed by this PR (if there is one) e.g. Fixes gatsbyjs#1234, Addresses gatsbyjs#1234, Related to gatsbyjs#1234, etc. --> Related to gatsbyjs#10612
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesHi, fixes #17102 - this is my first issue #goodnessSquad