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

ParameterDescription
TMap

Constructors

ConstructorAlertsDescription
(constructor)(parents)BetaConstructs a new instance of the DependencyContainer class

Properties

PropertyAlertsModifiersTypeDescription
IFluidDependencySynthesizerBetareadonlythis

Methods

MethodAlertsReturn TypeDescription
has(type, excludeParents)BetabooleanCheck if a given type is registered
register(type, provider)BetavoidAdd a new provider
synthesize(optionalTypes, requiredTypes)BetaAsyncFluidObjectProvider<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)BetavoidRemove 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

ParameterTypeDescription
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

ParameterModifiersTypeDescription
typestringType to check
excludeParentsoptionalboolean

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
ParameterConstraintDefaultDescription
Tkeyof TMapkeyof TMap

Parameters

ParameterTypeDescription
typeTName of the Type T being provided
providerFluidObjectProvider<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
ParameterDefaultDescription
O
Rundefined | Record<string, never>

Parameters

ParameterTypeDescription
optionalTypesFluidObjectSymbolProvider<O>optional types to be in the Scope object
requiredTypesRequired<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

ParameterTypeDescription
typekeyof TMapName of the provider to remove