Skip to content

Commit 8540cd3

Browse files
Update documentation for server.events.on()/.once() (#4372)
* Add documentation for context argument in server.events.on/once * Fix documentation for server.events.once() in summary
1 parent b8ba0ad commit 8540cd3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

API.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ Use the following methods to interact with `server.events`:
437437

438438
- [`server.event(events)`](#server.event()) - register application events.
439439
- [`server.events.emit(criteria, data)`](#server.events.emit()) - emit server events.
440-
- [`server.events.on(criteria, listener)`](#server.events.on()) - subscribe to all events.
441-
- [`server.events.once(criteria, listener)`](#server.events.once()) - subscribe to
440+
- [`server.events.on(criteria, listener, context)`](#server.events.on()) - subscribe to all events.
441+
- [`server.events.once(criteria, listener, context)`](#server.events.once()) - subscribe to a single event.
442442

443443
Other methods include: `server.events.removeListener(name, listener)`,
444444
`server.events.removeAllListeners(name)`, and `server.events.hasListeners(name)`.
@@ -1573,7 +1573,7 @@ async function example() {
15731573
}
15741574
```
15751575

1576-
### <a name="server.events.on()" /> `server.events.on(criteria, listener)`
1576+
### <a name="server.events.on()" /> `server.events.on(criteria, listener, context)`
15771577

15781578
Subscribe to an event where:
15791579

@@ -1622,6 +1622,7 @@ Subscribe to an event where:
16221622

16231623
- `listener` - the handler method set to receive event updates. The function signature depends on
16241624
the event argument, and the `spread` and `tags` options.
1625+
- `context` - an object that binds to the listener handler.
16251626

16261627
Return value: none.
16271628

@@ -1637,7 +1638,7 @@ async function example() {
16371638
}
16381639
```
16391640

1640-
### <a name="server.events.once()" /> `server.events.once(criteria, listener)`
1641+
### <a name="server.events.once()" /> `server.events.once(criteria, listener, context)`
16411642

16421643
Same as calling [`server.events.on()`](#server.events.on()) with the `count` option set to `1`.
16431644

0 commit comments

Comments
 (0)