Skip to content

Commit

Permalink
doc: fix worker example to receive message
Browse files Browse the repository at this point in the history
`require('worker_threads')` is not an instance of `EventEmitter`. So
`on` method would not be in it. The correct way to receive the message
would be to attach a listener to the `message` event on the
`parentPort`.
  • Loading branch information
thefourtheye committed Jul 17, 2018
1 parent ab10bfe commit d1b0121
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/worker_threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ added: v10.5.0
* `transferList` {Object[]}

Send a message to the worker that will be received via
[`require('worker_threads').on('message')`][].
[`require('worker_threads').parentPort.on('message')`][].
See [`port.postMessage()`][] for more details.

### worker.ref()
Expand Down Expand Up @@ -480,7 +480,7 @@ active handle in the event system. If the worker is already `unref()`ed calling
[`process.stdout`]: process.html#process_process_stdout
[`process.title`]: process.html#process_process_title
[`require('worker_threads').workerData`]: #worker_threads_worker_workerdata
[`require('worker_threads').on('message')`]: #worker_threads_event_message_1
[`require('worker_threads').parentPort.on('message')`]: #worker_threads_event_message
[`require('worker_threads').postMessage()`]: #worker_threads_worker_postmessage_value_transferlist
[`require('worker_threads').isMainThread`]: #worker_threads_worker_ismainthread
[`require('worker_threads').parentPort`]: #worker_threads_worker_parentport
Expand Down

0 comments on commit d1b0121

Please sign in to comment.