Represents a class that can be used to create a singleton instance of a class that is created asynchronously.

Type Parameters

  • T
  • R

Constructors

Methods

Constructors

  • Creates a new instance of the AsyncSingleton class.

    Type Parameters

    • T
    • R

    Parameters

    • factory: ((r: R) => Promise<T>)

      The factory function that creates the instance.

        • (r): Promise<T>
        • Parameters

          Returns Promise<T>

    • checker: ((value: T) => Promise<boolean>) = ...

      The function that checks if the instance is valid.

        • (value): Promise<boolean>
        • Parameters

          • value: T

          Returns Promise<boolean>

    Returns default<T, R>

Methods

  • Gets the instance of the class.

    Parameters

    • r: R

      The configuration object for creating the instance.

    Returns Promise<T>