On Sep 20, 2007 1:22 AM, Maciej Stachowiak <[EMAIL PROTECTED]> wrote:

> FWIW the async model would probably be easier to implement in the
> short run than worker threads, and we'd be hesitant to implement
> worker threads at all without a clear spec for which APIs should be
> available on worker threads. But in the long run I think having both
> is reasonable.


Agree.

That said, it will be even more common with databases to have multiple
asynchronous operations in a row than it is today with XHR. Doing this all
asynchronously will be incredibly painful.

I have done some thought on how to simplify the worker api, and I think it
could be as easy as:

var w = createWorker("foo.js");
w.sendMessage("messageName", jsonStyleObject);
w.addEventListener("messageName", function(e) {
  // e.args is a jsonStyleObject that was sent from the worker.
}, false);

Inside the worker:

worker.addEventListener("messageName", function(e) {
  // e.args is a jsonStyleObject that was sent from the worker.
}, false);
w.sendMessage("messageName", jsonStyleObject);

The main complication then will just be adding back access to the APIs you
need: XHR, database, cookies, timers, onerror, etc.

- a

Reply via email to