On 10/27/16 9:48 AM, Michał Wadas wrote:
Currently we put emphasis on request-response model - we request
something from function (returning Promise/taking callback) and we wait
for single return value. Workers are different beasts - they can emit
messages on their own and don't have to emit ANY messages on completion.

Right. The point of workers in the web platform is to do computation in a separate context. The computation need not be communicated back to the spawning page, because workers can do their own I/O.

// main.js
const worker = new Worker('worker.js');
worker.request('ajaxCall', {url: 'example.com <http://example.com>'});
// return Promise resolving to Response object
worker.request('undefinedMethod'); // return rejected Promise

// worker.js

self.on('ajaxCall', (data)=>{ return Promise.resolve(new Response); });

Workers in the web platform have a shared-nothing model. The above example seems to assume that the Response and the Promise are either shared across the main script and the worker or auto-cloned at the boundary, right?

-Boris
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to