Skip to main content
Version: 2.x

ResolverBuilder class

@microsoft/fast-element/di.js > ResolverBuilder

ResolverBuilder class

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

Signature:

export declare class ResolverBuilder<K> 

Constructors

Constructor

Modifiers

Description

(constructor)(container, key)

Constructs a new instance of the ResolverBuilder class

Methods

Method

Modifiers

Description

aliasTo(destinationKey)

Aliases the current key to a different key.

cachedCallback(value)

Creates a resolver that invokes a callback function the first time that a dependency resolution is requested. The returned value is then cached and provided for all subsequent requests.

callback(value)

Creates a resolver that invokes a callback function for every dependency resolution request, allowing custom logic to return the dependency.

instance(value)

Creates a resolver for an existing object instance.

singleton(value)

Creates a resolver that enforces a singleton lifetime.

transient(value)

Creates a resolver that creates a new instance for every dependency request.