diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-10-28 02:14:34 +0300 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2020-10-28 14:25:35 +0300 |
commit | ab660a541605a0a823f0c9471ff667a6620be2a5 (patch) | |
tree | 4a1c36711348d3618c730ecdba6f6e7e5e4b123c /doc/api/worker_threads.md | |
parent | 3df5afb367cf6ae4b6309ad54e1a9cb2e6884d27 (diff) |
doc: update MessagePort documentation for EventTarget inheritance
Refs: https://github.com/nodejs/node/pull/34057
Refs: https://github.com/nodejs/node/issues/35835
PR-URL: https://github.com/nodejs/node/pull/35839
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'doc/api/worker_threads.md')
-rw-r--r-- | doc/api/worker_threads.md | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 4b04930db2f..086e541013e 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -142,7 +142,7 @@ inherit from its global `Object` class. Objects passed to the and inherit from its global `Object` class. However, the created `MessagePort` will no longer inherit from -[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive +[`EventTarget`][], and only [`port.onmessage()`][] can be used to receive events using it. ## `worker.parentPort` @@ -297,17 +297,22 @@ port2.postMessage({ foo: 'bar' }); ## Class: `MessagePort` <!-- YAML added: v10.5.0 +changes: + - version: + - v14.7.0 + pr-url: https://github.com/nodejs/node/pull/34057 + description: This class now inherits from `EventTarget` rather than + from `EventEmitter`. --> -* Extends: {EventEmitter} +* Extends: {EventTarget} Instances of the `worker.MessagePort` class represent one end of an asynchronous, two-way communications channel. It can be used to transfer structured data, memory regions and other `MessagePort`s between different [`Worker`][]s. -With the exception of `MessagePort`s being [`EventEmitter`][]s rather -than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s. +This implementation matches [browser `MessagePort`][]s. ### Event: `'close'` <!-- YAML @@ -986,7 +991,6 @@ active handle in the event system. If the worker is already `unref()`ed calling [`Buffer`]: buffer.md [`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: errors.md#errors_err_missing_message_port_in_transfer_list [`ERR_WORKER_NOT_RUNNING`]: errors.md#ERR_WORKER_NOT_RUNNING -[`EventEmitter`]: events.md [`EventTarget`]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget [`FileHandle`]: fs.md#fs_class_filehandle [`KeyObject`]: crypto.md#crypto_class_keyobject |