2018-05-21 21:31:11 +00:00
|
|
|
console.log('hello from the worker');
|
|
|
|
|
|
|
|
function workerFunction() {
|
|
|
|
return 'worker function result';
|
|
|
|
}
|
|
|
|
|
2020-05-07 10:54:55 +00:00
|
|
|
self.addEventListener('message', (event) => {
|
2018-05-21 21:31:11 +00:00
|
|
|
console.log('got this data: ' + event.data);
|
|
|
|
});
|
|
|
|
|
2020-05-07 10:54:55 +00:00
|
|
|
(async function () {
|
2018-05-21 21:31:11 +00:00
|
|
|
while (true) {
|
|
|
|
self.postMessage(workerFunction.toString());
|
2020-05-07 10:54:55 +00:00
|
|
|
await new Promise((x) => setTimeout(x, 100));
|
2018-05-21 21:31:11 +00:00
|
|
|
}
|
2020-05-07 10:54:55 +00:00
|
|
|
})();
|