Class Factory<T>

Standard static-class factory. The token of this factory is a reference to a static class that is instantiated when the factory produces.

Dependency keys are inferred from injection metadata on the constructor's params, as are the injected properties.

Example

class A {
constructor(
protected readonly myService: MyService
) { }
}

const fact = new Factory(A)

fact.produce([myServiceInstance], []) // => A { myService: myServiceInstance }

Type Parameters

  • T

Hierarchy

Constructors

Properties

token: Instantiable<T>

Token that was registered for this factory. In most cases, this is the static form of the item that is to be produced by this factory.

Var

Methods

  • Should return true if the given identifier matches the token for this factory.

    Returns

    boolean

    Parameters

    • something: unknown

    Returns boolean

  • Produce an instance of the token.

    Parameters

    • dependencies: any[]

      the resolved dependencies, in order

    • parameters: any[]

      the bound constructor parameters, in order

    Returns any