W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2008

[whatwg] Combining the DedicatedWorker and SharedWorker interfaces

From: Aaron Boodman <aa@google.com>
Date: Tue, 4 Nov 2008 09:02:01 -0800
Message-ID: <278fd46c0811040902i2cecdf54p8231271ecf700e6f@mail.gmail.com>
2008/11/4 Alexey Proskuryakov <ap at webkit.org>:
> Nov 4, 2008, ? 10:08 AM, Aaron Boodman ???????(?):
>> Here's an example in code:
>>
>> // dedicated workers (outside)
>> var worker = new Worker("foo.js");
>> var port = worker.connect();
>> port.onmessage = function() { }
>> port.postMessage("ping");
>>
>> // dedicated workers (inside)
>> onconnect = function(e) {
>>  e.port.onmessage = function(e) {
>>   e.port.postMessage("pong");
>>  }
>> }
>
> I think this can be written as (note the different name of MessageEvent
> attribute, and the use of "this" in onmessage):
> onconnect = function(e) {
>  e.messagePort.onmessage = function() {
>   this.postMessage("pong");
>  }
> }

Right you are. Thanks for fixing.

>> Shared workers are exactly the same except the constructor is
>> SharedWorker("foo.js", "foo");
>
> Is there any benefit in having a different name for this constructor? If
> dedicated and shared workers are going to have identical implementation
> (notably, if they have exactly the same lifetime), I don't see any benefit
> in making them look different.

I don't have a strong opinion on this either way.

- a
Received on Tuesday, 4 November 2008 09:02:01 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:07 UTC