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

docs: Clearly document the behavior of ee.once(). #6371

Closed
wants to merge 4 commits into from
Closed

docs: Clearly document the behavior of ee.once(). #6371

wants to merge 4 commits into from

Conversation

lance
Copy link
Member

@lance lance commented Apr 25, 2016

Checklist
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

doc

Description of change

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.

@@ -130,7 +130,7 @@ myEmitter.emit('event');
```

Using the `eventEmitter.once()` method, it is possible to register a listener
that is immediately unregistered after it is called.
that is unregistered as it is called.
Copy link
Contributor

Choose a reason for hiding this comment

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

as it is called is still a bit ambiguous. Could you use before here?

@cjihrig
Copy link
Contributor

cjihrig commented Apr 25, 2016

LGTM with a comment.

@mscdex mscdex added doc Issues and PRs related to the documentations. events Issues and PRs related to the events subsystem / EventEmitter. labels Apr 25, 2016
@eljefedelrodeodeljefe
Copy link
Contributor

LGTM

@addaleax
Copy link
Member

LGTM but you may want to use doc: for your commit message; and if you want to reference the issue in it, I think it’s generally preferred to use the full github URL. You can also add an Fixes: header, I think.

@lance
Copy link
Member Author

lance commented Apr 25, 2016

@addaleax yeah, I committed with 'docs:' instead of 'doc:'. I was aware that Fixes: was available, but since I can't really close the issue, I just referenced it. Do you need these things to change before merging the PR?

@jasnell
Copy link
Member

jasnell commented Apr 25, 2016

@lance ... can you take a look at the new prependOnceListener() method description in the docs and see if it requires similar treatment?

@addaleax
Copy link
Member

@lance No, all of that can be taken care of when landing the commit. 😄

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.
Additional documentation changes required for `ee.prependOnceListener`
as per #5566.
@lance
Copy link
Member Author

lance commented Apr 25, 2016

@jasnell took a look and updated the documentation. Based on my reading of lib/events.js it seems the behavior would be identical.

*beginning* of the listeners array. This listener is invoked only the next time
`eventName` is triggered, after which it is removed.
*beginning* of the listeners array. This listener is removed, and then invoked
only the next time `eventName` is triggered.
Copy link
Member

Choose a reason for hiding this comment

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

To me this sounds a bit like the listener is removed instantly after being added. Maybe just copy the corresponding sentence for .once() from above?

@jasnell
Copy link
Member

jasnell commented Apr 25, 2016

LGTM

@jasnell jasnell added this to the 6.0.0 milestone Apr 25, 2016
@ChALkeR
Copy link
Member

ChALkeR commented Apr 25, 2016

LGTM

@Fishrock123 Fishrock123 removed this from the 6.0.0 milestone Apr 25, 2016
jasnell pushed a commit that referenced this pull request Apr 27, 2016
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 <[email protected]>
Reviewed-By: Robert Lindstaedt <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
@jasnell
Copy link
Member

jasnell commented Apr 27, 2016

Landed in 23818c6.
Fixed up the commit message a bit.

@jasnell jasnell closed this Apr 27, 2016
Fishrock123 pushed a commit that referenced this pull request May 4, 2016
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 <[email protected]>
Reviewed-By: Robert Lindstaedt <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
@MylesBorins
Copy link
Contributor

does not land cleanly on v4.x-staging. Would someone be willing to backport?

@MylesBorins
Copy link
Contributor

I'm going to mark this as don't land @lance / @nodejs/documentation please feel free to open a backport PR

@lance
Copy link
Member Author

lance commented Jun 2, 2016

@thealphanerd - submitted backport PR here #7103

I have not submitted anything for backport before. I hope it's all up to snuff.

MylesBorins pushed a commit that referenced this pull request Jun 2, 2016
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 <[email protected]>
Reviewed-By: Robert Lindstaedt <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 2, 2016
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 <[email protected]>
Reviewed-By: Robert Lindstaedt <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
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 <[email protected]>
Reviewed-By: Robert Lindstaedt <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
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 <[email protected]>
Reviewed-By: Robert Lindstaedt <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. events Issues and PRs related to the events subsystem / EventEmitter.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants