mirror of
https://github.com/denoland/deno.git
synced 2024-11-04 08:54:20 -05:00
7966bf14c0
* split ops/worker.rs into ops/worker_host.rs and ops/web_worker.rs * refactor js/workers.ts and factor out js/worker_main.ts - entry point for WebWorker runtime * BREAKING CHANGE: remove support for blob: URL in Worker * BREAKING CHANGE: remove Deno namespace support and noDenoNamespace option in Worker constructor * introduce WebWorker struct which is a stripped down version of cli::Worker
20 lines
541 B
TypeScript
20 lines
541 B
TypeScript
const jsWorker = new Worker("./subdir/test_worker.js", { type: "module" });
|
|
const tsWorker = new Worker("./subdir/test_worker.ts", { type: "module" });
|
|
|
|
tsWorker.onmessage = (e): void => {
|
|
console.log("Received ts: " + e.data);
|
|
};
|
|
|
|
jsWorker.onmessage = (e): void => {
|
|
console.log("Received js: " + e.data);
|
|
|
|
tsWorker.postMessage("Hello World");
|
|
};
|
|
|
|
jsWorker.onerror = (e: Event): void => {
|
|
e.preventDefault();
|
|
console.log("called onerror in script");
|
|
jsWorker.postMessage("Hello World");
|
|
};
|
|
|
|
jsWorker.postMessage("Hello World");
|