@libreworks/container
    Preparing search index...

    Class Container

    A simplistic asynchronous dependency injection container.

    Hierarchy

    • EventTarget
      • Container
    Index

    Constructors

    • Create a new Container.

      Parameters

      • providers: Map<string, Provider<unknown>>

        A Map of providers by name.

      • logger: Logger = nullLogger

        The logger instance, default: no logs

      Returns Container

    Methods

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Gets a named component from the container.

      Type Parameters

      • T = any

      Parameters

      • name: string

        The component name.

      Returns Promise<T>

      A promise that resolves to the registered component

      if no component is registered with the provided name.

    • Gets multiple named components from the container.

      Type Parameters

      • T = any

      Parameters

      • names: ArrayLike<string> | Iterable<string, any, any>

        The component names.

      Returns Promise<T[]>

      A Promise that resolves to the registered components

      if no component is registered with one of the provided names.

    • Gets any components registered under a specific tag.

      Type Parameters

      • T = any

      Parameters

      • tag: string

        The tag.

      Returns Promise<T[]>

      A Promise that resolves to the tagged components.

    • Gets the names of all registered components.

      Returns string[]

      The registered component names.

    • Checks if the container holds a named component.

      If this method returns true, invoking get with the same parameter will not throw a RangeError.

      Parameters

      • name: string

        The component name.

      Returns boolean

      Whether the component exists in the container

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void