• Function to get a singleton. To create the singleton, the parameter create is used. This will be called once. The singleton will be stored as global variable and can be accessed by the identifier

    Author

    M.Karkowski

    Export

    Returns

    An object, containing the key instances, where you'll find the instance and an helper function setInstance to redefine the instance

    Type Parameters

    • T

      The Type of the singleton

    Parameters

    • identifier: string

      Identifier to access the singleton

    • create: (() => T)

      The Callback which is used to create the instance.

        • (): T
        • Returns T

    Returns {
        instance: T;
        setInstance: ((value) => void);
    }

    • instance: T
    • setInstance: ((value) => void)
        • (value): void
        • Parameters

          • value: T

          Returns void

Generated using TypeDoc