Function construct

  • Equivalent to Inject.map([...deps], args => new ctor(...args)).

    Type Parameters

    Parameters

    • ctor: (new (...args) => T)

      A constructor that produces the desired resource

        • new (...args): T
        • Parameters

          Returns T

    • Rest ...deps: K

      A list of dependencies that resolve to ctor's arguments

    Returns Map<T, K, G>

    Example

    Providing a default injection for a class:

    class User {
    name: string; id: number
    constructor(name: string, id: number) {
    this.name = name; this.id = id
    }

    static inject = Inject.construct(this, NameKey, IdKey)
    }

Generated using TypeDoc