Closed prateekbh closed 3 years ago
That’s a much more invasive change to the HTML spec and needs a lot more thought: How was worker
initialized? What does execute actually do? What is the return value of execute()
?
If it does what I think you want it to do, it can easily be built on top of the existing postMessage()
infrastructure.
That being said, at some point I would like to investigate something like a proper ModuleWorker
:
const api = new ModuleWorker(module {
export function add(a, b) {
return a + b;
}
});
console.log(await api.add(40, 2)); // Logs 42
Sorry if this was already discussed or if this feels like bikeshedding.
re-using
postMessage
seems a bit confusing, would it make it a bit more readable if it wereworker.execute(module { export function fn() { return "hello!" } })
?execute/run/etc
Keen to hear your thoughts