Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

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

💧EventEmitter's typesafe replacement
Go to Latest
interface Worker
import { type Worker } from "https://deno.land/x/evt@v2.5.3/lib/types/lib.dom.ts";

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