I have a function that spawns a worker
function fetchFile(mes) {
const worker = new Worker('worker.js');
worker.postMessage(mes);
//somehow return the message returned by the worker
}
worker.js:
self.onmessage = function (msg) {
//some complex calculations
}
and I want to return the value calculated by the worker for the function
is there a way to do this?