Assembles configuration for a dependency injection container.

Constructors

  • Creates a new Builder.

    Parameters

    • logger: Logger = nullLogger

      The logger instance.

    Returns Builder

Methods

  • Builds a new container and resets the builder to a default state.

    Returns Promise<Container>

    The Promised container.

  • Registers a constant value as a component.

    Type Parameters

    • T

    Parameters

    • name: string

      The name of the component.

    • value: T

      The static value to register as the component.

    Returns this

    provides a fluent interface.

  • Determines if a named component has been added to the builder.

    Parameters

    • name: string

      The component name to check.

    Returns boolean

    Whether the component factory is present.

  • Registers a component.

    The factory parameter must be a Function that returns the component. You can provide an async function or one that returns a Promise.

    The tags parameter must be an Array of string values. There are a few tags with special meanings:

    • @eager - The component will be instantiated when the container is built.

    Type Parameters

    • T

    Parameters

    • name: string

      The name of the component.

    • factory: Factory<T>

      A function that returns the component.

    • tags: string[] = []

      An optional array of string tags for the component.

    Returns this

    provides a fluent interface.

  • Abandons registered components and resets the builder to a default state.

    Returns void