• A decorator to register an instance of a class in the DI (Dependency Injection) container. The instance is created only when it is first needed (Lazy Initialization).

    Type Parameters

    • TargetType extends (new (..._args: unknown[]) => InstanceType<TargetType>)

      The type of the class whose instance is to be registered.

    Parameters

    • identifier: string

      The identifier used to register the instance in the DI container.

    • Optionalinit: InitDelegate<TargetType & (new (..._args: unknown[]) => InstanceType<TargetType>), InstanceType<TargetType>>

      An optional initializer function which get the constructor of the class as input and returns an instance of the class.

    Returns ((constructor: TargetType, ...args: unknown[]) => void)

    A function that is applied as a decorator to the class.

      • (constructor, ...args): void
      • Parameters

        Returns void

    \@RegisterInstance('MyClassInstanceIdentifier', arg1, arg2)
    class MyClass {
    // ...
    }