Interface Injector

Injector API.

interface Injector {
    inject<Instance>(Class: Constructor<Instance>): Instance;
    inject<Value>(token: Token<Value>): Value;
    inject<Values>(...tokens: TokenList<Values>): Values[number];
    injectAll<Instance>(Class: Constructor<Instance>): Instance[];
    injectAll<Value>(token: Token<Value>): NonNullable<Value>[];
    injectAll<Values>(...tokens: TokenList<Values>): NonNullable<Values[number]>[];
}

Methods

  • Inject instances of a class with all registered providers.

    Type Parameters

    • Instance extends object

    Parameters

    Returns Instance[]

  • Inject instances of a token with all registered providers.

    The returned array will not contain null or undefined values.

    Type Parameters

    • Value

    Parameters

    Returns NonNullable<Value>[]

  • Inject instances of a token with all registered providers, by checking each token in order until a registered one is found.

    The returned array will not contain null or undefined values.

    Type Parameters

    • Values extends unknown[]

    Parameters

    Returns NonNullable<Values[number]>[]