Confirmed users
716
edits
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 138: | Line 138: | ||
Downsides with this proposal: | Downsides with this proposal: | ||
* There is no way to communicate back unless first communicated to. | * There is no way to communicate back unless first communicated to. | ||
* The first one to instantiate a shared worker get special treatment. | |||
=== Proposal 2 === | === Proposal 2 === | ||
| Line 159: | Line 160: | ||
</blockquote> | </blockquote> | ||
<code>connectToSharedWorker</code> creates a new <code> | <code>connectToSharedWorker</code> creates a two new <code>MessagePort</code> which are entangled with each other. One of the two ports is returned, and the other is sent to the <code>Worker</code> with the given name. If such a <code>Worker</code> does not yet exist, one is created. | ||
The <code>Worker</code> receives the other <code>MessagePort</code> through an <code>onconnect</code> <code>Event</code> fired on the <code>WorkerGlobalScope</code> object. | |||
* There is no way to get a reference to the shared <code>Worker</code> object itself. | |||
* Communication for shared workers is different from communication for non-shared ones. | |||
* | |||