-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
docs,events: ee.once() event ordering differs from documentation #5566
Comments
It's also worth noting this has been the behaviour since it was introduced (but I would also prefer fixing the ordering). |
It looks like the documentation was added in 179a7f6 and has always mis documented the function. Modifying the behavior would be a semver major change. Modifying the documentation would be a semver patch change which could be backported to v4 / v5. In reality the doc change should potentially happen even if the behavior is changed on master. Is there an advantage to the behavior change aside from accurately following what was documented? |
For one, it enforces logically correct ordering. You might want to, for example, log stuff after a handler is run for the last time just before being removed.
|
I was going to submit a PR with @zeusdeux suggested change, but this ends up breaking one of the I can fix this test, but I wonder if this doesn't illustrate some potential brittleness to this change. Update: I tried changing the It seems to me, that unless you are willing to accept a possibly breaking change, the best course is to just change the documentation. Two node.js tests expect behavior as it is today. You can be sure user code does as well. |
@lance @thealphanerd Just a doc update makes sense to me |
+1 to doc update. |
@nodejs/documentation |
Addresses #5566. The `ee.once()` function is currently documented as invoking the listener, and then removing it when the event is triggered. However, this is not really the case. The listener is removed and _then_ invoked. This only matters in a narrow set of use cases, but when it matters, it matters that the docs are correct. See the issue (#5566) for a discussion on why the code has not been modified to match the documentation, but instead the documentation has been modified to match the code. Fixes: #5566 PR-URL: #6371 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Addresses #5566. The `ee.once()` function is currently documented as invoking the listener, and then removing it when the event is triggered. However, this is not really the case. The listener is removed and _then_ invoked. This only matters in a narrow set of use cases, but when it matters, it matters that the docs are correct. See the issue (#5566) for a discussion on why the code has not been modified to match the documentation, but instead the documentation has been modified to match the code. Fixes: #5566 Ref: #6371 PR-URL: #7103 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Addresses #5566. The `ee.once()` function is currently documented as invoking the listener, and then removing it when the event is triggered. However, this is not really the case. The listener is removed and _then_ invoked. This only matters in a narrow set of use cases, but when it matters, it matters that the docs are correct. See the issue (#5566) for a discussion on why the code has not been modified to match the documentation, but instead the documentation has been modified to match the code. Fixes: #5566 Ref: #6371 PR-URL: #7103 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Addresses #5566. The `ee.once()` function is currently documented as invoking the listener, and then removing it when the event is triggered. However, this is not really the case. The listener is removed and _then_ invoked. This only matters in a narrow set of use cases, but when it matters, it matters that the docs are correct. See the issue (#5566) for a discussion on why the code has not been modified to match the documentation, but instead the documentation has been modified to match the code. Fixes: #5566 Ref: #6371 PR-URL: #7103 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Addresses #5566. The `ee.once()` function is currently documented as invoking the listener, and then removing it when the event is triggered. However, this is not really the case. The listener is removed and _then_ invoked. This only matters in a narrow set of use cases, but when it matters, it matters that the docs are correct. See the issue (#5566) for a discussion on why the code has not been modified to match the documentation, but instead the documentation has been modified to match the code. Fixes: #5566 Ref: #6371 PR-URL: #7103 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Documentation describes
ee.once()
behaviour as (emphasis mine)The actual current behaviour is for the listener to removed, and then invoked.
The text was updated successfully, but these errors were encountered: