IFluidContainer Interface
Provides an entrypoint into the client side of collaborative Fluid data. Provides access to the data as well as status on the collaboration session.
Signature
export interface IFluidContainer extends IEventProvider<IFluidContainerEvents>
Extends: IEventProvider<IFluidContainerEvents
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 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 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> | A newly created container starts detached from the collaborative service. Calling attach() uploads the new container to the service and connects to the collaborative service. |
connect() | 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() | void | Disconnects the container from the delta stream and stops processing operations. |
dispose() | void | Dispose of the container instance, permanently disabling it. |
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
readonly attachState: AttachState;
Type: AttachState
connectionState
Provides the current connected state of the container
Signature
readonly connectionState: ConnectionState;
Type: ConnectionState
disposed
Whether the container is disposed, which permanently disables it.
Signature
readonly 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
readonly 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:
-
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. -
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
readonly isDirty: boolean;
Type: boolean
Method Details
attach
A newly created container starts detached from the collaborative service. Calling attach()
uploads the new container to the service and connects to the collaborative service.
Signature
attach(): Promise<string>;
Remarks
This should only be called when the container is in the @fluidframework/container-definitions#AttachState.Detatched state.
This can be determined by observing attachState.
Returns
A promise which resolves when the attach is complete, with the string identifier of the container.
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(): 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.
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
Disconnects the container from the delta stream and stops processing operations.
Signature
disconnect(): void;
Remarks
This should only be called when the container is in the @fluidframework/container-definitions#ConnectionState.Connected state.
This can be determined by observing connectionState.
dispose
Dispose of the container instance, permanently disabling it.
Signature
dispose(): void;