Skip to content 

DependencyContainer Class

Packages > @fluidframework/synthesize > DependencyContainer

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

Signature:

export declare class DependencyContainer implements IFluidDependencySynthesizer 

Implements: IFluidDependencySynthesizer

Constructors

List of constructors for this class
Constructor Modifiers Description
(constructor)(parent) Constructs a new instance of the DependencyContainer class

Properties

List of properties for this class
Property Modifiers Type Description
IFluidDependencySynthesizer this
parent IFluidDependencySynthesizer | undefined
registeredTypes Iterable<(keyof IFluidObject)> All the registered types available

Methods

List of methods on this class
Method Modifiers Description
getProvider(type) Get a provider. undefined if not available.
has(types) Check if a given type is registered
register(type, provider) Add a new provider
synthesize(optionalTypes, requiredTypes) 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) Remove a provider

Constructors

DependencyContainer.(constructor)

Constructs a new instance of the DependencyContainer class

Signature:

constructor(parent?: IFluidDependencySynthesizer | undefined);

Parameters

List of parameters
Parameter Type Description
parent IFluidDependencySynthesizer | undefined

Properties

IFluidDependencySynthesizer

Signature:

get IFluidDependencySynthesizer(): this;

parent

Signature:

parent: IFluidDependencySynthesizer | undefined;

registeredTypes

All the registered types available

Signature:

get registeredTypes(): Iterable<(keyof IFluidObject)>;

Methods

getProvider

Get a provider. undefined if not available.

Signature:

getProvider<T extends keyof IFluidObject>(type: T): FluidObjectProvider<T> | undefined;

Parameters

List of parameters
Parameter Type Description
type T Type to get

Returns:

FluidObjectProvider<T> | undefined

has

Check if a given type is registered

Signature:

has(...types: (keyof IFluidObject)[]): boolean;

Parameters

List of parameters
Parameter Type Description
types (keyof IFluidObject)[] Type to check

Returns:

boolean

register

Add a new provider

Signature:

register<T extends keyof IFluidObject>(type: T, provider: FluidObjectProvider<T>): void;

Parameters

List of parameters
Parameter Type Description
type T Name of the Type T being provided
provider FluidObjectProvider A provider that will resolve the T correctly when asked

Returns:

void

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.

Signature:

synthesize<O extends IFluidObject, R extends IFluidObject = {}>(optionalTypes: FluidObjectSymbolProvider<O>, requiredTypes: FluidObjectSymbolProvider<R>): AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<R>>;

Parameters

List of parameters
Parameter Type Description
optionalTypes FluidObjectSymbolProvider optional types to be in the Scope object
requiredTypes FluidObjectSymbolProvider required types that need to be in the Scope object

Returns:

AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<R>>

unregister

Remove a provider

Signature:

unregister<T extends keyof IFluidObject>(type: T): void;

Parameters

List of parameters
Parameter Type Description
type T Name of the provider to remove

Returns:

void