Skip to main content

ISharedObjectKind Interface

Defines a kind of shared object. Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.

This API is provided for existing users, but is not recommended for new users.

To use, import via fluid-framework/legacy.

For more information about our API support guarantees, see here.

Signature​

export interface ISharedObjectKind<TSharedObject>

Type Parameters​

ParameterDescription
TSharedObject

Remarks​

For use internally and in the "encapsulated API". See SharedObjectKind for the type erased version for use in the public declarative API.

Methods​

MethodAlertsReturn TypeDescription
create(runtime, id)BetaTSharedObjectCreate a shared object.
getFactory()BetaIChannelFactory<TSharedObject>Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.

Method Details​

create​

Create a shared object.

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​

create(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;

Remarks​

The created object is local (detached): insert a handle to it into an attached object to share (attach) it. If using @fluidframework/fluid-static (for example via @fluidframework/azure-client), use create(objectClass) instead of calling this directly.

Example​

To create a SharedTree, call the static create method:

const myTree = SharedTree.create(this.runtime, id);

Parameters​

ParameterModifiersTypeDescription
runtimeIFluidDataStoreRuntimeThe data store runtime that the new shared object belongs to.
idoptionalstringOptional name of the shared object.

Returns​

Newly created shared object.

Return type: TSharedObject

getFactory​

Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.

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​

getFactory(): IChannelFactory<TSharedObject>;

Remarks​

The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels. To create new shared objects use:

  • create(objectClass) if using @fluidframework/fluid-static, for example via @fluidframework/azure-client.

Returns​

Return type: IChannelFactory<TSharedObject>