Re: Shared workers - use .source instead of .ports[0] ?

Sounds great to me. The ports attribute is basically useless except in this
one instance since ports are these days expose as part of structured clones.

Avoiding using it in this arguably weird way in this one instance seems
like a win to me.

/ Jonas

On Wednesday, April 4, 2012, Simon Pieters wrote:

> Hi,
>
> In Opera Extensions we use something that resembles shared workers. One
> modification is that the 'connect' event's source port is exposed in
> .source instead of in .ports[0], to make it closer to the API for
> cross-document messaging. Maybe we should make this change to Shared
> Workers as well.
>
> I think shared workers hasn't seen wide adoption yet, so maybe changes
> like this are still possible.
>
> What do people think?
>
> currently:
> onconnect = function(e) { e.ports[0].postMessage('pong') }
>
> proposed change:
> onconnect = function(e) { e.source.postMessage('pong') }
>
> --
> Simon Pieters
> Opera Software
>
>

Received on Wednesday, 4 April 2012 16:38:17 UTC