Skip to main content

@fluidframework/presence Package

Package for client presence within a connected session.

See README.md for an overview of the package.

Interfaces

Interface Alerts Modifiers Description
Attendee Alpha sealed A client within a Fluid session (period of container connectivity to service).
AttendeesEvents Alpha sealed
BroadcastControls Alpha sealed Common controls for States objects.
BroadcastControlSettings Alpha Value set to configure BroadcastControls.
LatestArguments Alpha Arguments that are passed to the StateFactory.latest function.
LatestClientData Alpha sealed State of a specific attendee's value and its metadata.
LatestData Alpha sealed State of a value and its metadata.
LatestMapArguments Alpha Arguments that are passed to the StateFactory.latestMap function.
LatestMapClientData Alpha sealed Collection of latest known values for a specific client.
LatestMapItemRemovedClientData Alpha sealed Identifier and metadata for a removed item.
LatestMapItemUpdatedClientData Alpha sealed State of a single item value, its key, and its metadata.
LatestMapRaw Alpha sealed State that provides a Map of latest known values from this client to others and read access to their values. Entries in the map may vary over time and by client, but all values are expected to be of the same type, which may be a union type.
LatestMapRawEvents Alpha sealed
LatestMetadata Alpha sealed Metadata for the value state.
LatestRaw Alpha sealed State that provides the latest known value from this client to others and read access to their values. All participant clients must provide a value.
LatestRawEvents Alpha sealed
NotificationEmitter Alpha sealed Interface for a notification emitter that can send typed notification to other clients.
NotificationListenable Alpha sealed An object which allows the registration of listeners so that subscribers can be notified when a notification happens.
NotificationsManager Alpha sealed Provides notifications from this client to others and subscription to their notifications.
NotificationsManagerEvents Alpha sealed
NotificationsWorkspace Alpha sealed NotificationsWorkspace maintains a registry of NotificationsManagers that facilitate messages across client members in a session.
NotificationsWorkspaceSchema Alpha

Schema for a NotificationsWorkspace workspace.

Keys of schema are the keys of the NotificationsWorkspace providing access to NotificationsManagers.

Presence Alpha sealed Presence represents known clients within a session and their custom states and notifications.
PresenceEvents Alpha sealed
StateMap Alpha sealed Map of local client's values. Modifications are transmitted to all other connected clients.
StatesWorkspace Alpha sealed

StatesWorkspace maintains a registry of State objects that all share and provide access to presence state values across client members in a session.

State objects offer variations on how to manage states, but all share same principle that each client's state is independent and may only be updated by originating client.

StatesWorkspaceSchema Alpha

Schema for a StatesWorkspace workspace.

Keys of schema are the keys of the StatesWorkspace providing access to State objects.

Classes

Class Alerts Modifiers Description
ExperimentalPresenceDO Alpha sealed Brand for Experimental Presence Data Object.

Types

TypeAlias Alerts Modifiers Description
AttendeeId Alpha A Fluid client session identifier.
AttendeeStatus Alpha

Represents the connection status of an Attendee.

This type can be either 'Connected' or 'Disconnected', indicating whether the attendee is currently connected to the Fluid service.

When 'Disconnected': - State changes are kept locally and communicated to others upon reconnect. - Notification requests are discarded (silently).

ClientConnectionId Alpha A Fluid client connection identifier.
NotificationSubscriptions Alpha sealed Record of notification subscriptions.
StatesWorkspaceEntries Alpha sealed Map of State objects registered with StatesWorkspace.
StatesWorkspaceEntry Alpha Single entry in StatesWorkspaceSchema or NotificationsWorkspaceSchema.
WorkspaceAddress Alpha Unique address within a session.

Functions

Function Alerts Return Type Description
getPresence(fluidContainer) Alpha Presence Acquire an Presence from a Fluid Container
getPresenceViaDataObject(fluidLoadable) Alpha Presence Acquire Presence from a DataStore based Presence Manager
latest(args) Alpha InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>> Factory for creating a LatestRaw State object.
latestMap(args) Alpha InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMapRaw<T, Keys>> Factory for creating a LatestMapRaw State object.
Notifications(initialSubscriptions) Alpha InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>> Factory for creating a NotificationsManager.

Variables

Variable Alerts Modifiers Type Description
AttendeeStatus Alpha readonly { readonly Connected: "Connected"; readonly Disconnected: "Disconnected"; } The connection status of the Attendee.
ExperimentalPresenceManager Alpha readonly SharedObjectKind<IFluidLoadable & ExperimentalPresenceDO> DataStore based Presence Manager that is used as fallback for preferred Container Extension based version requires registration. Export SharedObjectKind for registration.
StateFactory Alpha readonly { latest: typeof latest; latestMap: typeof latestMap; } Factory for creating presence State objects.

Namespaces

Namespace Alerts Description
InternalTypes System Collection of value types that are not intended to be used/imported directly outside of this package.
InternalUtilityTypes System Collection of utility types that are not intended to be used/imported directly outside of this package.

Function Details

getPresence

Acquire an Presence from a Fluid Container

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

To use, import via @fluidframework/presence/alpha.

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

Signature

export declare function getPresence(fluidContainer: IFluidContainer): Presence;

Parameters

Parameter Type Description
fluidContainer IFluidContainer Fluid Container to acquire the map from

Returns

the Presence

Return type: Presence

getPresenceViaDataObject

Acquire Presence from a DataStore based Presence Manager

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

To use, import via @fluidframework/presence/alpha.

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

Signature

export declare function getPresenceViaDataObject(fluidLoadable: ExperimentalPresenceDO): Presence;

Example

const containerSchema = {
initialObjects: {
experimentalPresence: ExperimentalPresenceDO,
},
} satisfies ContainerSchema;

then

const presence = getPresenceViaDataObject(
container.initialObjects.experimentalPresence,
);

Parameters

Parameter Type Description
fluidLoadable ExperimentalPresenceDO

Returns

Return type: Presence

latest

Factory for creating a LatestRaw State object.

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

To use, import via @fluidframework/presence/alpha.

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

Signature

export declare function latest<T extends object | null, Key extends string = string>(args: LatestArguments<T>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>>;
Type Parameters
Parameter Constraint Default Description
T object | null
Key string string

Parameters

Parameter Type Description
args LatestArguments<T>

Returns

Return type: InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>>

latestMap

Factory for creating a LatestMapRaw State object.

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

To use, import via @fluidframework/presence/alpha.

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

Signature

export declare function latestMap<T, Keys extends string | number = string | number, RegistrationKey extends string = string>(args?: LatestMapArguments<T, Keys>): InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMapRaw<T, Keys>>;
Type Parameters
Parameter Constraint Default Description
T
Keys string | number string | number
RegistrationKey string string

Parameters

Parameter Modifiers Type Description
args optional LatestMapArguments<T, Keys>

Returns

Return type: InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMapRaw<T, Keys>>

Notifications

Factory for creating a NotificationsManager.

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

To use, import via @fluidframework/presence/alpha.

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

Signature

export declare function Notifications<T extends InternalUtilityTypes.NotificationListeners<T>, Key extends string = string>(initialSubscriptions: Partial<NotificationSubscriptions<T>>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>;
Type Parameters
Parameter Constraint Default Description
T InternalUtilityTypes.NotificationListeners<T>
Key string string

Remarks

Typescript inference for Notifications is not working correctly yet. Explicitly specify generics to make result types usable.

Parameters

Parameter Type Description
initialSubscriptions Partial<NotificationSubscriptions<T>>

Returns

Return type: InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>

Variable Details

AttendeeStatus

The connection status of the Attendee.

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

To use, import via @fluidframework/presence/alpha.

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

Signature

AttendeeStatus: {
readonly Connected: "Connected";
readonly Disconnected: "Disconnected";
}

Type: { readonly Connected: "Connected"; readonly Disconnected: "Disconnected"; }

ExperimentalPresenceManager

DataStore based Presence Manager that is used as fallback for preferred Container Extension based version requires registration. Export SharedObjectKind for registration.

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

To use, import via @fluidframework/presence/alpha.

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

Signature

ExperimentalPresenceManager: SharedObjectKind<IFluidLoadable & ExperimentalPresenceDO>

Type: SharedObjectKind<IFluidLoadable & ExperimentalPresenceDO>

StateFactory

Factory for creating presence State objects.

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

To use, import via @fluidframework/presence/alpha.

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

Signature

StateFactory: {
latest: typeof latest;
latestMap: typeof latestMap;
}

Type: { latest: typeof latest; latestMap: typeof latestMap; }