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 @fluidframework/shared-object-base/legacy.

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

Signature

export interface ISharedObjectKind<TSharedObject>

Type Parameters

Parameter Description
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

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

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/shared-object-base/alpha.

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

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.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/shared-object-base/alpha.

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:

Returns

Return type: IChannelFactory<TSharedObject>