[This post doesn't belong here and is definitely not worth reading.]
I think it would be nice to be able to perform Promise-based communication between threads, similar to the service worker's fetch resolution.
There is no special specification for this method name. I am aware that it may be confused with the existing Request object, and believe there is a better name.
Main thread script:
const requestWorker = new Worker("./path/to/worker.js");
const workerResponse = await requestWorker.postRequest({ a: 2, b: 3 }); // 5
Worker script:
self.addEventListener("request", e => {
const { a, b } = e.data;
e.respondWith(a + b);
})
This may allow you to explicitly return the transferred object after certain processing is completed.