web Worker API suggestion

Hi,
Not sure this is the best email to contact you guys regarding an API
suggestion, but here it goes:


I've been thinking about this for a while now, and I think it would be
beneficial to update the Worker api to allow you to pass a IIFI function
instead of a external file?

From: current Worker API:

const worker = new Worker('lame.js');
worker.onmessage = (e) => {
console.log(e);
};

// lame.js
this.addEventListener('message', (e) => {
this.postMessage({ message: 'hello back' });
});


to

const worker = new Worker(() => {
this.addEventListener('message', (e) => {
this.postMessage({ message: 'hello back' });
});
});
worker.onmessage = (e) => {
console.log(e);
};


Wouldn't this be better?

Thanks
Andre

Received on Sunday, 13 May 2018 15:10:33 UTC