interface WebWorkerLike

Minimal shape of a web Worker instance as used by this host.

Properties

onmessage: ((event: { data: unknown; }) => void) | null

Message handler slot; events carry the payload in data.

onerror: ((event: unknown) => void) | null

Error handler slot; events carry a message when available.

Methods

postMessage(message: unknown): void

Posts a structured-clonable message to the worker.

addEventListener(
type: string,
listener: (event: unknown) => void
): void

Registers an event listener. Only used for the runtime-specific worker-ended event named by WebWorkerHostOptions.exitEventName, which is not part of the web Worker standard and therefore has no handler slot.

terminate(): void

Terminates the worker.

Usage

import { type WebWorkerLike } from "runtime/src/index.ts";