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

[whatwg] createEvent() in Web Workers?

From: Jonathan Cook <jonathan.j5.cook@gmail.com>
Date: Fri, 27 Nov 2009 07:50:21 -0800
Message-ID: <4B0FF53D.5050907@gmail.com>
I would like to see createEvent in WebWorker.  My (theoretical) use case
would involve using custom eventing to load or set new message
handlers.  Flow would be something like this

window A creates worker 1
window A sends message to worker 1
worker 1 sends message to window A
window A sends message to worker 1
worker 1 creates an event "switch" in response to message, passing the
message in the event: createEvent("switch",message)
worker 1 switch event handler loads / sets new message handler, mutating
itself into worker 1 sub 1 and calls the new message handler on the
passed message
worker 1 sub 1 sends message to window A

Anyone think this theoretical use case or some derivative is a useful
abstraction to aid in code organization and flow control?  I would think
since an eventing queue is specified for message handling that adding
custom events would not be much additional effort for implementers.

initErrorEvent would seem to put the DOM Events Level 3 createEvent and
initEvent methods together.  Is there a reason that this approach was
chosen instead of mirroring DOM Events?  The simple answer seems to be
because there is no DOM :)


Simon Pieters wrote:
> There's ErrorEvent.initErrorEvent, and dispatchEvent is exposed in 
> workers, but there's no createEvent (because there's no document). Are 
> there use cases for sending events in a worker? Should we expose 
> createEvent somewhere? Should we remove initErrorEvent?
Received on Friday, 27 November 2009 07:50:21 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:54 UTC