Packages > @fluidframework/shared-object-base > ISharedObjectKind

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.

Signature

export interface ISharedObjectKind<TSharedObject>

Type Parameters

Parameter Description
TSharedObject

Methods

Method Return Type Description
create(runtime, id) TSharedObject Create a shared object.
getFactory() IChannelFactory<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.

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

Parameter Modifiers Type Description
runtime IFluidDataStoreRuntime The data store runtime that the new shared object belongs to.
id optional string Optional 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.

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:

Returns

Return type: IChannelFactory <TSharedObject>