@lppedd/di-wise-neo - v0.6.0
    Preparing search index...

    Interface Injector

    Injector API.

    interface Injector {
        inject<Instance extends object>(Class: Constructor<Instance>): Instance;
        inject<Value>(token: Token<Value>): Value;
        injectAll<Instance extends object>(
            Class: Constructor<Instance>,
        ): Instance[];
        injectAll<Value>(token: Token<Value>): NonNullable<Value>[];
        optional<Instance extends object>(
            Class: Constructor<Instance>,
        ): undefined | Instance;
        optional<Value>(token: Token<Value>): undefined | Value;
        optionalAll<Instance extends object>(
            Class: Constructor<Instance>,
        ): Instance[];
        optionalAll<Value>(token: Token<Value>): NonNullable<Value>[];
    }
    Index

    Methods

    • Injects all instances provided by the registrations associated with the given class.

      Throws an error if the class is not registered in the container.

      Type Parameters

      • Instance extends object

      Parameters

      Returns Instance[]

    • Injects all values provided by the registrations associated with the given token.

      Throws an error if the token is not registered in the container.

      Type Parameters

      • Value

      Parameters

      Returns NonNullable<Value>[]

    • Injects all instances provided by the registrations associated with the given class, or an empty array if the class is not registered in the container.

      Type Parameters

      • Instance extends object

      Parameters

      Returns Instance[]

    • Injects all values provided by the registrations associated with the given token, or an empty array if the token is not registered in the container.

      Type Parameters

      • Value

      Parameters

      Returns NonNullable<Value>[]