Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WorkerLike

A worker implementation.

Hierarchy

  • WorkerLike

Implemented by

Index

Properties

error: string | Error

Gets the error state of the terminated worker.

returns

A string or Error that describes the error state of the current worker; undefined if the current worker was forcibly terminated via WorkerLike.terminate().

onMessage: TypedEvent<WorkerMessage<unknown>>

Gets the current worker state.

returns

A WorkerStateFlags value that describes the current state of the worker.

Methods

  • postMessage(data: Record<string, unknown>): Promise<void>
  • Sends a message to the worker.

    remarks

    Once the promise returned by this method resolves, it indicates that the message has been delivered to the worker and not that the worker has successfully processed the message.

    Parameters

    • data: Record<string, unknown>

      The data that should be posted to the current worker.

    Returns Promise<void>

    A Promise that resolves once data has been successfuly sent to the worker.

  • start(): Promise<void>
  • Starts the current worker.

    Returns Promise<void>

    A Promise that resolves when the current worker has completed executing.

  • terminate(): void
  • Signals the current worker to terminate immediately.

    Returns void

  • wait(): Promise<void>
  • Waits until the current worker has completed executing.

    Returns Promise<void>

    A Promise that resolves when the current worker has completed executing.

Generated using TypeDoc