Skip to main content
Version: 2.x

Classes

Class

Description

ResolverBuilder

A utility class used that constructs and registers resolvers for a dependency injection container. Supports a standard set of object lifetimes.

Functions

Function

Description

all(key, searchAncestors)

A decorator and DI resolver that will resolve an array of all dependencies registered with the specified key.

ignore(target, property, descriptor)

A decorator that tells the container not to try to inject a dependency.

inject(dependencies)

A decorator that specifies what to inject into its target.

lazy(key)

A decorator that lazily injects a dependency depending on whether the Key is present at the time of function call.

newInstanceForScope(key)

A decorator that indicates that a new instance should be injected scoped to the container that requested the instance.

newInstanceOf(key)

A decorator that indicates that a new instance should be injected.

optional(key)

A decorator that allows you to optionally inject a dependency depending on whether the [[Key]] is present, for example:

singleton()

Registers the decorated class as a singleton dependency; the class will only be created once. Each consecutive time the dependency is resolved, the same instance will be returned.

singleton(options)

singleton(target)

Registers the target class as a singleton dependency; the class will only be created once. Each consecutive time the dependency is resolved, the same instance will be returned.

transient()

Registers the decorated class as a transient dependency; each time the dependency is resolved a new instance will be created.

transient(target)

Registers the target class as a transient dependency; each time the dependency is resolved a new instance will be created.

Interfaces

Interface

Description

Container

Implemented by dependency injection containers.

ContainerConfiguration

Configuration for a dependency injection container.

DOMContainer

A Container that is associated with a specific Node in the DOM.

Factory

Used by the default Resolver to create instances of objects when needed.

InterfaceConfiguration

Used to configure a dependency injection interface key.

Registration

Implemented by objects that wish to register dependencies in the container by creating resolvers.

Registry

Implemented by objects that which to register dependencies in a container.

Resolver

Internally, the DI system maps "keys" to "resolvers". A resolver controls how a dependency is resolved. Resolvers for transient, singleton, etc. are provided out of the box, but you can also implement Resolver yourself and supply custom logic for resolution.

ServiceLocator

Implemented by objects capable of resolving services and other dependencies.

Variables

Variable

Description

Container

The key that resolves the dependency injection Container itself.

ContainerConfiguration

Configuration for a dependency injection container.

DefaultResolver

A set of default resolvers useful in configuring a container.

DI

The gateway to dependency injection APIs.

DOMContainer

The key that resolves a DOMContainer itself.

Registration

You can use the resulting Registration of any of the factory methods to register with the container.

ServiceLocator

The key that resolves the ServiceLocator itself.

Type Aliases

Type Alias

Description

AsyncRegistrationLocator

A function capable of asynchronously locating a resolver for a key.

Injectable

A class that declares constructor injected dependencies through a static "inject" field array of keys.

Key

A key that is used to register dependencies with a dependency injection container.

ParentLocator

A function capable of locating the parent container based on a container's owner.

RegisterSelf

Represents an object that can register itself.

ResolveCallback

Represents a custom callback for resolving a request from the container. The handler is the container that is invoking the callback. The requestor is the original container that made the request. The handler and the requestor may not be the same if the request has bubbled up to a parent container in the DI hierarchy. The resolver is the instance of the resolver that stores the callback. This is provided in case the callback needs a place or key against which to store state across resolutions.

Resolved

Represents something resolved from a service locator.

Transformer_2

Transforms an object after it is created but before it is returned to the requestor.