Interface TunnelOpts<A>

interface TunnelOpts<A> {
    id?: string;
    interrupt?: boolean;
    maxWorkers?: number;
    src: string | Blob | Worker | Fn0<Worker>;
    terminate?: number;
    transferables?: Fn<A, any[]>;
}

Type Parameters

  • A

Properties

id?: string

Optional subscription ID to use.

interrupt?: boolean

If true, the worker will be terminated and restarted for each new stream value. This is useful to avoid executing extraneous work and ensures only the most rececent stream value is being processed.

Default: false

maxWorkers?: number

Max. number of worker instances to use. Only useful if interrupt is disabled. If more than one worker is used, incoming stream values will be assigned in a round robin manner and result value ordering will be non-deterministic. Workers will be instantiated on demand.

Default: 1

src: string | Blob | Worker | Fn0<Worker>

Tunnelled worker instance, source blob or script URL. If interrupt is enabled, the worker MUST be given as blob or URL.

terminate?: number

If given and greater than zero, all workers will be terminated after given period (in millis) after the parent stream is done.

Default: 1000

transferables?: Fn<A, any[]>

Optional function to extract transferables from incoming stream values, e.g. ArrayBuffers. See: https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage

Generated using TypeDoc