February 2018
Intermediate to advanced
298 pages
8h 22m
English
Sometimes, it might be required to terminate a worker within the worker when the worker is performing some sort of async task whose duration can be variable. There is a method called close() available inside the worker for that purpose:
// myworker.jsaddEventListener('message', e => { if(e.data.message == "doAjaxAndDie") { fetch(...).then(data => { postMessage(data); close(); // or self.close(); }); }});
Read now
Unlock full access