Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b46187

Browse filesBrowse files
lanceMyles Borins
authored andcommitted
doc: Backport ee.once doc clarifications to 4.x.
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>
1 parent 4067cde commit 3b46187
Copy full SHA for 3b46187

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Collapse file

‎doc/api/events.markdown‎

Copy file name to clipboardExpand all lines: doc/api/events.markdown
+3-4Lines changed: 3 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ myEmitter.emit('event');
130130
```
131131

132132
Using the `eventEmitter.once()` method, it is possible to register a listener
133-
that is immediately unregistered after it is called.
133+
that is unregistered before it is called.
134134

135135
```js
136136
const myEmitter = new MyEmitter();
@@ -338,9 +338,8 @@ Returns a reference to the `EventEmitter` so calls can be chained.
338338

339339
### emitter.once(eventName, listener)
340340

341-
Adds a **one time** `listener` function for the event named `eventName`. This
342-
listener is invoked only the next time `eventName` is triggered, after which
343-
it is removed.
341+
Adds a **one time** `listener` function for the event named `eventName`. The
342+
next time `eventName` is triggered, this listener is removed and then invoked.
344343

345344
```js
346345
server.once('connection', (stream) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.