Worker
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.
interface Worker extends EventTarget, AbstractWorker {
onmessage: ((this: Worker, ev: MessageEvent) => any) | null;
onmessageerror: ((this: Worker, ev: MessageEvent) => any) | null;
addEventListener<K extends keyof WorkerEventMap>(
type: K,
listener: (this: Worker, ev: WorkerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
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,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;terminate(): void;
}var Worker: {
prototype: Worker;
new (scriptURL: string | URL, options?: WorkerOptions): Worker;
};§Properties
§
onmessage: ((this: Worker, ev: MessageEvent) => any) | null
[src]§
onmessageerror: ((this: Worker, ev: MessageEvent) => any) | null
[src]§Methods
§
addEventListener<K extends keyof WorkerEventMap>(
[src]type: K,
listener: (this: Worker, ev: WorkerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void§
addEventListener(
[src]type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void§
Clones message and transmits it to worker's global environment. transfer can be passed as a list of objects that are to be transferred rather than cloned.
§
removeEventListener<K extends keyof WorkerEventMap>(
[src]type: K,
listener: (this: Worker, ev: WorkerEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void§
removeEventListener(
[src]type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void