2020-01-21 03:49:47 -05:00
|
|
|
const jsWorker = new Worker("./subdir/test_worker.js", { type: "module" });
|
|
|
|
const tsWorker = new Worker("./subdir/test_worker.ts", { type: "module" });
|
2019-04-01 15:09:59 -04:00
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
tsWorker.onmessage = (e): void => {
|
2019-04-01 15:09:59 -04:00
|
|
|
console.log("Received ts: " + e.data);
|
|
|
|
};
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
jsWorker.onmessage = (e): void => {
|
2019-04-01 15:09:59 -04:00
|
|
|
console.log("Received js: " + e.data);
|
|
|
|
|
|
|
|
tsWorker.postMessage("Hello World");
|
|
|
|
};
|
|
|
|
|
2020-01-17 18:43:53 -05:00
|
|
|
jsWorker.onerror = (e: Event): void => {
|
|
|
|
e.preventDefault();
|
|
|
|
console.log("called onerror in script");
|
|
|
|
jsWorker.postMessage("Hello World");
|
|
|
|
};
|
|
|
|
|
2019-04-01 15:09:59 -04:00
|
|
|
jsWorker.postMessage("Hello World");
|