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

doc: emitter.removeListener within emit cycle clarification #4764

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/events.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ Removes the specified `listener` from the listener array for the specified
`removeListener` will remove, at most, one instance of a listener from the
listener array. If any single listener has been added multiple times to the
listener array for the specified `event`, then `removeListener` must be called
multiple times to remove each instance.
multiple times to remove each instance. Listeners removed from an event from
within the emit cycle of that event will still be called in that emit cycle.
Copy link
Contributor

Choose a reason for hiding this comment

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

The term emit cycle isn't defined anywhere, is it? It might be better to say that it will run all listeners attached at the time an event is emitted. This is sort of tricky to explain just in text, and a code example would be extremely helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would argue that a unit test to prove that this happens would be good too.


Because listeners are managed using an internal array, calling this will
change the position indices of any listener registered *after* the listener
Expand Down