Module

x/evt/lib/index.ts>dom.Worker

šŸ’§EventEmitter's typesafe replacement
Go to Latest
interface dom.Worker
import { type dom } from "https://deno.land/x/evt@v2.3.1/lib/index.ts";
const { Worker } = dom;

This Web Workers API interface represents a background task that can be easily created and can send messages back to its creator. Creating a worker is as simple as calling the Worker() constructor and specifying a script to be run in the worker thread.

Properties

onmessage: ((this: Worker, ev: MessageEvent) => any) | null

Methods

postMessage(message: any, transfer: Transferable[]): void
postMessage(message: any, options?: PostMessageOptions): void
terminate(): void
addEventListener<K extends keyof WorkerEventMap>(
type: K,
listener: (this: Worker, ev: WorkerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
removeEventListener<K extends keyof WorkerEventMap>(
type: K,
listener: (this: Worker, ev: WorkerEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void