WorkerInterface<T> Type
Given an interface T that defines the operations provided by a worker, produce an interface that can be used to asynchronously invoke those operations from the main thread, optionally passing an array of values to be transferred from the main thread to the worker.
- Every return type is converted to a
Promise
(i.e., every function becomesasync
)>. zeroArgFunc(): R
becomesasync zeroArgFunc(): Promise<R>
.oneArgFunc(arg: U): R
becomesasync oneArgFunc(arg: U, transfer?: Transferable[]): Promise<R>
.multiArgFunc(arg1: U, arg2: V): R
becomesasync multiArgFunc(args: [U, V], transfer?: Transferable[]): Promise<R>
.
@note All parameters of all methods of T
must support structured cloning -
attempts to pass functions, instances of classes, DOM nodes, WebGL resources, and other non-cloneable types will compile but fail at run-time.
Defined in
Last Updated: 21 November, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.