2020-01-29 12:54:23 -05:00
|
|
|
const jsWorker = new Worker("./subdir/test_worker.js", {
|
|
|
|
type: "module",
|
|
|
|
name: "jsWorker"
|
|
|
|
});
|
|
|
|
const tsWorker = new Worker("./subdir/test_worker.ts", {
|
|
|
|
type: "module",
|
|
|
|
name: "tsWorker"
|
|
|
|
});
|
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");
|