Skip to main content
Version: v1

FluidContainer Class

Base IFluidContainer implementation.

Signature

export declare class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer

Extends: TypedEventEmitter<IFluidContainerEvents

Implements: IFluidContainer

Remarks

Note: this implementation is not complete. Consumers who rely on attach() will need to utilize or provide a service-specific implementation of this type that implements that method.

Constructors

Constructor Description
(constructor)(container, rootDataObject) Constructs a new instance of the FluidContainer class

Properties

Property Type Description
attachState AttachState The current attachment state of the container. Once a container has been attached, it remains attached. When loading an existing container, it will already be attached.
connectionState ConnectionState Provides the current connected state of the container
disposed boolean Whether the container is disposed, which permanently disables it.
initialObjects LoadableObjectRecord The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema. These data objects and DDSes exist for the lifetime of the container.
isDirty boolean

A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service. You should always check the isDirty flag before closing the container or navigating away from the page. Closing the container while isDirty === true may result in the loss of operations that have not yet been acknowledged by the service.

A container is considered dirty in the following cases:

1. The container has been created in the detached state, and either it has not been attached yet or it is in the process of being attached (container is in attaching state). If container is closed prior to being attached, host may never know if the file was created or not.

2. The container was attached, but it has local changes that have not yet been saved to service endpoint. This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the service. In some cases this can be due to lack of network connection. If the network connection is down, it needs to be restored for the pending changes to be acknowledged.

Methods

Method Return Type Description
attach() Promise<string> Incomplete base implementation of attach().
connect() Promise<void> Attempts to connect the container to the delta stream and process operations. Will throw an error if unsuccessful.
create(objectClass) Promise<T> Create a new data object or Distributed Data Store (DDS) of the specified type.
disconnect() Promise<void> Attempts to connect the container to the delta stream and process operations. Will throw an error if unsuccessful.
dispose() void Dispose of the container instance, permanently disabling it.

Constructor Details

(constructor)

Constructs a new instance of the FluidContainer class

Signature

constructor(container: IContainer, rootDataObject: RootDataObject);

Parameters

Parameter Type Description
container IContainer
rootDataObject RootDataObject

Property Details

attachState

The current attachment state of the container. Once a container has been attached, it remains attached. When loading an existing container, it will already be attached.

Signature

get attachState(): AttachState;

Type: AttachState

connectionState

Provides the current connected state of the container

Signature

get connectionState(): ConnectionState;

Type: ConnectionState

disposed

Whether the container is disposed, which permanently disables it.

Signature

get disposed(): boolean;

Type: boolean

initialObjects

The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema. These data objects and DDSes exist for the lifetime of the container.

Signature

get initialObjects(): LoadableObjectRecord;

Type: LoadableObjectRecord

isDirty

A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service. You should always check the isDirty flag before closing the container or navigating away from the page. Closing the container while isDirty === true may result in the loss of operations that have not yet been acknowledged by the service.

A container is considered dirty in the following cases:

  1. The container has been created in the detached state, and either it has not been attached yet or it is in the process of being attached (container is in attaching state). If container is closed prior to being attached, host may never know if the file was created or not.

  2. The container was attached, but it has local changes that have not yet been saved to service endpoint. This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the service. In some cases this can be due to lack of network connection. If the network connection is down, it needs to be restored for the pending changes to be acknowledged.

Signature

get isDirty(): boolean;

Type: boolean

Method Details

attach

Incomplete base implementation of attach().

Signature

attach(): Promise<string>;

Remarks

Note: this implementation will unconditionally throw. Consumers who rely on this will need to utilize or provide a service specific implementation of this base type that provides an implementation of this method.

The reason is because externally we are presenting a separation between the service and the FluidContainer, but internally this separation is not there.

Returns

Return type: Promise<string>

connect

Attempts to connect the container to the delta stream and process operations. Will throw an error if unsuccessful.

Signature

connect(): Promise<void>;

Remarks

This should only be called when the container is in the @fluidframework/container-definitions#ConnectionState.Disconnected state.

This can be determined by observing connectionState.

Returns

Return type: Promise<void>

create

Create a new data object or Distributed Data Store (DDS) of the specified type.

Signature

create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
Type Parameters
Parameter Constraint Description
T IFluidLoadable

Remarks

In order to share the data object or DDS with other collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your initialObjects.

Parameters

Parameter Type Description
objectClass LoadableObjectClass<T> The class of data object or DDS to create

Returns

Return type: Promise<T>

disconnect

Attempts to connect the container to the delta stream and process operations. Will throw an error if unsuccessful.

Signature

disconnect(): Promise<void>;

Remarks

This should only be called when the container is in the @fluidframework/container-definitions#ConnectionState.Disconnected state.

This can be determined by observing connectionState.

Returns

Return type: Promise<void>

dispose

Dispose of the container instance, permanently disabling it.

Signature

dispose(): void;