Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WorkerFeature Abstract

Represents an extrinsic worker feature that can be used to extend the capabilities of workers.

remarks

Classes derived from WorkerFeature should be aware that their instances are transient, and created for each instance of the worker that is being decorated. As such, implementations are free to hold state specific to each worker instance if necessary.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

  • Initializes the base WorkerFeature instance.

    Parameters

    • worker: WorkerLike

      The worker to adapt with the feature.

    • Optional messagePort: MessagePort

      The channel to the parent worker that created worker.

    Returns WorkerFeature

Properties

messagePort?: MessagePort
worker: WorkerLike

Methods

  • get(key: string | symbol): unknown
  • Returns a value or a function that is a proxy for a method or property being accessed on the underlying worker.

    remarks

    The base WorkerFeature class returns undefined, but derived implementations should override WorkerFeature.get(...) in order to return appropriate proxies.

    virtual

    Parameters

    • key: string | symbol

      The key being acccessed.

    Returns unknown

    A value or a function that is a proxy for key. Returns undefined if no proxy can to satisfy key.

  • tryGet<T>(target: T): InstanceType<T>
  • Retrieves a worker feature for the current worker thread.

    Type Parameters

    Parameters

    Returns InstanceType<T>

    The WorkerFeature instance for target, or undefined if the current worker thread has not been decorated with the feature described by target.

Generated using TypeDoc