Skip to main content

DependencyContainer Class

DependencyContainer is similar to a IoC Container. It takes providers and will synthesize an object based on them when requested. \

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/synthesize/legacy.

For more information about our API support guarantees, see here.

Signature

export declare class DependencyContainer<TMap> implements IFluidDependencySynthesizer

Implements: IFluidDependencySynthesizer

Type Parameters

Parameter Description
TMap

Constructors

Constructor Alerts Description
(constructor)(parents) Beta Constructs a new instance of the DependencyContainer class

Properties

Property Alerts Modifiers Type Description
IFluidDependencySynthesizer Beta readonly this

Methods

Method Alerts Return Type Description
has(type, excludeParents) Beta boolean Check if a given type is registered
register(type, provider) Beta void Add a new provider
synthesize(optionalTypes, requiredTypes) Beta AsyncFluidObjectProvider<O, R> synthesize takes optional and required types and returns an object that will fulfill the defined types based off objects that has been previously registered.
unregister(type) Beta void Remove a provider

Constructor Details

(constructor)

Constructs a new instance of the DependencyContainer class

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
constructor(...parents: (IFluidDependencySynthesizer | undefined)[]);

Parameters

Parameter Type Description
parents (IFluidDependencySynthesizer | undefined)[]

Property Details

IFluidDependencySynthesizer

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
get IFluidDependencySynthesizer(): this;

Type: this

Method Details

has

Check if a given type is registered

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
has(type: string, excludeParents?: boolean): boolean;

Parameters

Parameter Modifiers Type Description
type string Type to check
excludeParents optional boolean

Returns

Return type: boolean

register

Add a new provider

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
register<T extends keyof TMap = keyof TMap>(type: T, provider: FluidObjectProvider<Pick<TMap, T>>): void;
Type Parameters
Parameter Constraint Default Description
T keyof TMap keyof TMap

Parameters

Parameter Type Description
type T Name of the Type T being provided
provider FluidObjectProvider<Pick<TMap, T>> A provider that will resolve the T correctly when asked
Error Handling
  • If passing a type that's already registered

synthesize

synthesize takes optional and required types and returns an object that will fulfill the defined types based off objects that has been previously registered.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
synthesize<O, R = undefined | Record<string, never>>(optionalTypes: FluidObjectSymbolProvider<O>, requiredTypes: Required<FluidObjectSymbolProvider<R>>): AsyncFluidObjectProvider<O, R>;
Type Parameters
Parameter Default Description
O
R undefined | Record<string, never>

Parameters

Parameter Type Description
optionalTypes FluidObjectSymbolProvider<O> optional types to be in the Scope object
requiredTypes Required<FluidObjectSymbolProvider<R>> required types that need to be in the Scope object

Returns

Return type: AsyncFluidObjectProvider<O, R>

unregister

Remove a provider

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
unregister(type: keyof TMap): void;

Parameters

Parameter Type Description
type keyof TMap Name of the provider to remove