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.

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

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

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

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

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

Extollo Logo

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

Extollo is a free & libre application framework in TypeScript.