Skip to main content
Version: 2.x

newInstanceForScope() function

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

newInstanceForScope() function

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

Signature:

newInstanceForScope: (key: any) => any

Parameters

Parameter

Type

Description

key

any

The dependency key for the new instance.

Returns:

any

Remarks

This creates a resolver with an instance strategy pointing to the new instance, effectively making this a singleton, scoped to the container or DOM's subtree.