Packages > @fluidframework/fluid-static > IFluidContainer
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.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents>
Extends: IEventProvider<IFluidContainerEvents >
Type Parameters
Parameter | Modifiers | Description |
---|---|---|
TContainerSchema | optional | Used to determine the type of 'initialObjects'. |
Remarks
Note: external implementations of this interface are not supported.
Properties
Property | Alerts | Modifiers | Type | Description |
---|---|---|---|---|
attachState |
ALPHA
|
readonly
|
AttachState | The current attachment state of the container. |
connectionState |
ALPHA
|
readonly
|
ConnectionState | Provides the current connected state of the container |
disposed |
ALPHA
|
readonly
|
boolean | Whether or not the container is disposed, which permanently disables it. |
initialObjects |
ALPHA
|
readonly
|
InitialObjects<TContainerSchema> | The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema. |
isDirty |
ALPHA
|
readonly
|
boolean | A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service. |
Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
attach() |
ALPHA
|
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() |
ALPHA
|
void | Attempts to connect the container to the delta stream and process operations. |
create(objectClass) |
ALPHA
|
Promise<T> | Create a new data object or Distributed Data Store (DDS) of the specified type. |
disconnect() |
ALPHA
|
void | Disconnects the container from the delta stream and stops processing operations. |
dispose() |
ALPHA
|
void | Dispose of the container instance, permanently disabling it. |
Property Details
attachState (ALPHA)
The current attachment state of the container.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
readonly attachState: AttachState;
Remarks
Once a container has been attached, it remains attached. When loading an existing container, it will already be attached.
connectionState (ALPHA)
Provides the current connected state of the container
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
readonly connectionState: ConnectionState;
disposed (ALPHA)
Whether or not the container is disposed, which permanently disables it.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
readonly disposed: boolean;
initialObjects (ALPHA)
The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
readonly initialObjects: InitialObjects<TContainerSchema>;
Remarks
These data objects and DDSes exist for the lifetime of the container.
isDirty (ALPHA)
A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
readonly isDirty: boolean;
Remarks
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.
Method Details
attach (ALPHA)
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.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
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 (ALPHA)
Attempts to connect the container to the delta stream and process operations.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
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 .
Error Handling
Will throw an error if connection is unsuccessful.
create (ALPHA)
Create a new data object or Distributed Data Store (DDS) of the specified type.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
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 the DataObject or SharedObject to create.
|
Returns
Return type: Promise<T>
disconnect (ALPHA)
Disconnects the container from the delta stream and stops processing operations.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
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 (ALPHA)
Dispose of the container instance, permanently disabling it.
WARNING: This API is provided as an alpha preview and may change without notice. Use at your own risk.
Signature
dispose(): void;