Type alias WorkerFunction<T>

WorkerFunction<T>: ((message?: T) => Promise<WorkerFunctionTransferArgs> | WorkerFunctionTransferArgs)

Type Parameters

  • T = unknown

    Anything passed in runJob, with Transferable objects inlined.

Type declaration

    • (message?: T): Promise<WorkerFunctionTransferArgs> | WorkerFunctionTransferArgs
    • The function which will process all jobs sent to this engine instance. May be sync or async. Worker functions cannot use variables defined outside of their block, because the function code itself is inlined and written to the Web Worker source code.

      You can safely throw errors in this function as they will be catched and bubbled up from the engine.

      Parameters

      • Optional message: T

      Returns Promise<WorkerFunctionTransferArgs> | WorkerFunctionTransferArgs

Generated using TypeDoc