Options
All
  • Public
  • Public/Protected
  • All
Menu

A container of resolve-able dependencies that are created via inversion-of-control.

Hierarchy

Index

Constructors

constructor

Properties

Protected factories

factories: Collection<AbstractFactory<unknown>> = ...

Collection of factories registered with this container.

Protected instances

instances: Collection<InstanceRef> = ...

Collection of singleton instances produced by this container.

Protected staticOverrides

staticOverrides: Collection<{ base: StaticInstantiable<any>; override: StaticInstantiable<any> }> = ...

Collection of static-class overrides registered with this container.

Protected waitingResolveCallbacks

waitingResolveCallbacks: Collection<{ callback: (t: unknown) => unknown; key: any }> = ...

Collection of callbacks waiting for a dependency key to be resolved.

Methods

cloneTo

getDependencies

  • Get a collection of dependency keys required by the given target, if it is registered with this container.

    Parameters

    • target: any

    Returns Collection<any>

getExistingInstance

  • getExistingInstance(key: any): any
  • Get the already-produced value for the given key, if one exists.

    Parameters

    • key: any

    Returns any

getStaticOverride

hasInstance

  • hasInstance(key: any): boolean
  • Returns true if the container has an already-produced value for the given key.

    Parameters

    • key: any

    Returns boolean

hasKey

  • hasKey(key: any): boolean
  • Returns true if the container has a factory for the given key.

    Parameters

    • key: any

    Returns boolean

hasStaticOverride

make

  • make<T>(target: any, ...parameters: any[]): T
  • Create an instance of the given target. The target can either be a DependencyKey registered with this container (in which case, the singleton value will be returned), or an instantiable class.

    If the instantiable class has the Injectable decorator, its injectable parameters will be automatically injected into the instance.

    Type parameters

    • T

    Parameters

    • target: any
    • Rest ...parameters: any[]

    Returns T

makeByStaticOverride

onResolve

  • onResolve<T>(key: any): Promise<T>
  • Get a Promise that resolves the first time the given dependency key is resolved by the application. If it has already been resolved, the Promise will resolve immediately.

    Type parameters

    • T

    Parameters

    • key: any

    Returns Promise<T>

Protected produceFactory

  • Given a factory and manually-provided parameters, resolve the dependencies for the factory and produce its value.

    Type parameters

    • T

    Parameters

    Returns T

purge

register

registerFactory

registerNamed

  • Register a basic instantiable class as a standard Factory with this container, identified by a string name rather than static class.

    Parameters

    • name: string

      unique name to identify the factory in the container

    • dependency: Instantiable<any>

    Returns Container

registerProducer

  • registerProducer(name: any, producer: () => any): Container
  • Register the given function as a factory within the container.

    Parameters

    • name: any

      unique name to identify the factory in the container

    • producer: () => any

      factory to produce a value

        • (): any
        • Returns any

    Returns Container

registerSingleton

  • registerSingleton<T>(key: any, value: T): Container
  • Register a value as a singleton in the container. It will not be instantiated, but can be injected by its unique name.

    Type parameters

    • T

    Parameters

    • key: any

      unique name to identify the singleton in the container

    • value: T

    Returns Container

registerSingletonInstance

  • registerSingletonInstance<T>(staticClass: any, instance: T): Container
  • Register a static class to the container along with its already-instantiated instance that will be used to resolve the class.

    Type parameters

    • T

    Parameters

    • staticClass: any
    • instance: T

    Returns Container

registerStaticOverride

release

resolve

resolveAndCreate

  • resolveAndCreate(key: any, ...parameters: any[]): any
  • Resolve the dependency key. If a singleton value for that key already exists in this container, return that value. Otherwise, use the factory an given parameters to produce and return the value.

    Parameters

    • key: any
    • Rest ...parameters: any[]

    Returns any

Static getContainer

Static realizeContainer

  • realizeContainer<T>(container: T): T
  • Given a Container instance, apply the ContainerBlueprint to it.

    Type parameters

    Parameters

    • container: T

    Returns T

Extollo Logo

extollo (v. latin) - to lift up, to elevate

Extollo is a free & libre application framework in TypeScript.