Skip to content

Commit 5c0a903

Browse files
committedOct 27, 2020
doc: update MessagePort documentation for EventTarget inheritance
Refs: nodejs#34057 Refs: nodejs#35835
1 parent cb62f16 commit 5c0a903

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎doc/api/worker_threads.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ inherit from its global `Object` class. Objects passed to the
142142
and inherit from its global `Object` class.
143143

144144
However, the created `MessagePort` will no longer inherit from
145-
[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive
145+
[`EventTarget`][], and only [`port.onmessage()`][] can be used to receive
146146
events using it.
147147

148148
## `worker.parentPort`
@@ -297,17 +297,22 @@ port2.postMessage({ foo: 'bar' });
297297
## Class: `MessagePort`
298298
<!-- YAML
299299
added: v10.5.0
300+
changes:
301+
- version:
302+
- v14.7.0
303+
pr-url: https://github.com/nodejs/node/pull/34057
304+
description: This class now inherits from `EventTarget` rather than
305+
from `EventEmitter`.
300306
-->
301307

302-
* Extends: {EventEmitter}
308+
* Extends: {EventTarget}
303309

304310
Instances of the `worker.MessagePort` class represent one end of an
305311
asynchronous, two-way communications channel. It can be used to transfer
306312
structured data, memory regions and other `MessagePort`s between different
307313
[`Worker`][]s.
308314

309-
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
310-
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
315+
This implementation matches [browser `MessagePort`][]s.
311316

312317
### Event: `'close'`
313318
<!-- YAML
@@ -986,7 +991,6 @@ active handle in the event system. If the worker is already `unref()`ed calling
986991
[`Buffer`]: buffer.md
987992
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: errors.md#errors_err_missing_message_port_in_transfer_list
988993
[`ERR_WORKER_NOT_RUNNING`]: errors.md#ERR_WORKER_NOT_RUNNING
989-
[`EventEmitter`]: events.md
990994
[`EventTarget`]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
991995
[`FileHandle`]: fs.md#fs_class_filehandle
992996
[`KeyObject`]: crypto.md#crypto_class_keyobject

0 commit comments

Comments
 (0)