Skip to main content

IChannelFactory Interface

Definitions of a channel factory.

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

To use, import via @fluidframework/datastore-definitions/legacy.

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

Signature

export interface IChannelFactory<out TChannel = unknown>

Type Parameters

Parameter Default Description
TChannel unknown

Remarks

The runtime must be able to produce "channels" of the correct in-memory object type for the collaborative session. Here "channels" are typically distributed data structures (DDSs).

The runtime will consult with a registry of such factories during Container load and when receiving "attach" operations (ops), which indicate a new instance of a channel being introduced to the collaboration session, to produce the appropriate in-memory object.

Factories follow a common model but enable custom behavior.

Example

If a collaboration includes a SharedMap, the collaborating clients will need to have access to a factory that can produce the SharedMap object.

Properties

Property Alerts Modifiers Type Description
attributes Alpha readonly IChannelAttributes Attributes of the channel.
type Alpha readonly string String representing the type of the factory.

Methods

Method Alerts Return Type Description
create(runtime, id) Alpha TChannel & IChannel Creates a local version of the channel. Calling attach on the object later will insert it into the object stream.
load(runtime, id, services, channelAttributes) Alpha Promise<TChannel & IChannel> Loads the given channel. This call is only ever invoked internally as the only thing that is ever directly loaded is the document itself. Load will then only be called on documents that were created and added to a channel.

Property Details

attributes

Attributes of the channel.

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

To use, import via @fluidframework/datastore-definitions/alpha.

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

Signature

readonly attributes: IChannelAttributes;

Type: IChannelAttributes

type

String representing the type of the factory.

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

To use, import via @fluidframework/datastore-definitions/alpha.

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

Signature

readonly type: string;

Type: string

Method Details

create

Creates a local version of the channel. Calling attach on the object later will insert it into the object stream.

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

To use, import via @fluidframework/datastore-definitions/alpha.

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

Signature

create(runtime: IFluidDataStoreRuntime, id: string): TChannel & IChannel;

Parameters

Parameter Type Description
runtime IFluidDataStoreRuntime The runtime the new object will be associated with
id string The unique ID of the new object

Returns

The newly created object.

Return type: TChannel & IChannel

load

Loads the given channel. This call is only ever invoked internally as the only thing that is ever directly loaded is the document itself. Load will then only be called on documents that were created and added to a channel.

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

To use, import via @fluidframework/datastore-definitions/alpha.

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

Signature

load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<TChannel & IChannel>;

Parameters

Parameter Type Description
runtime IFluidDataStoreRuntime Data store runtime containing state/info/helper methods about the data store.
id string ID of the channel.
services IChannelServices Services to read objects at a given path using the delta connection.
channelAttributes Readonly<IChannelAttributes> The attributes for the the channel to be loaded.

Returns

The loaded object

Return type: Promise<TChannel & IChannel>