Class LazyConstructor<T>

Sometimes, the creation of an new Instance is very slow. Therefore this Lazy-Constructor could be used. Instead of creating a new Instance, it looks for a not used and returns that Instance. By returning the unused Instance it is marked as used. After the usage the instance could marked as unused again. If there is no unused Instance available an new Instance is created.

To utilize the Lazy-Constructor a specific create-instance method and a compare function is required.

Export

Template

Type of the Instance

Type Parameters

  • T

    Args which are required to Construct an Instance

Hierarchy

  • LazyConstructor

Constructors

Methods

  • Creates a new Instance and tries to use an already existing one if possible.

    Returns

    new Object

    Memberof

    LazyConstructor

    Parameters

    • Rest ...args: any[]

      An Object containing the args which are required to create an Instance

    Returns T

  • Releases a used Instance. Thereby it could be used again.

    Memberof

    LazyConstructor

    Parameters

    • instance: T

    Returns void

Generated using TypeDoc