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

InterfaceAlertsModifiersDescription
AttendeeBetasealedA client within a Fluid session (period of container connectivity to service).
AttendeesEventsBetasealedEvents from attendees.
BroadcastControlsBetasealedCommon controls for States objects.
BroadcastControlSettingsBetaValue set to configure BroadcastControls.
LatestBetasealedState that provides the latest known value from this client to others and read access to their values. All participant clients must provide a value.
LatestArgumentsBetaArguments that are passed to the StateFactory.latest function to create a Latest State object.
LatestArgumentsRawBetaArguments that are passed to the StateFactory.latest function to create a LatestRaw State object.
LatestClientDataBetasealedState of a specific Attendee's value and its metadata.
LatestDataBetasealedState of a value and its metadata.
LatestEventsBetasealedEvents from LatestRaw.
LatestFactoryBetasealedFactory for creating a Latest or LatestRaw State object.
LatestMapBetasealedState 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.
LatestMapArgumentsBetaArguments that are passed to the StateFactory.latestMap function.
LatestMapArgumentsRawBetaArguments that are passed to the StateFactory.latestMap function.
LatestMapClientDataBetasealedCollection of latest known values for a specific Attendee.
LatestMapEventsBetasealedEvents from LatestMapRaw.
LatestMapFactoryBetasealedFactory for creating a LatestMap or LatestMapRaw State object.
LatestMapItemRemovedClientDataBetasealedIdentifier and metadata for a removed item.
LatestMapItemUpdatedClientDataBetasealedState of a single item value, its key, and its metadata.
LatestMetadataBetasealedMetadata for the value state.
NotificationEmitterAlphasealedInterface for a notification emitter that can send typed notification to other clients.
NotificationListenableAlphasealedAn object which allows the registration of listeners so that subscribers can be notified when a notification happens.
NotificationsManagerAlphasealedProvides notifications from this client to others and subscription to their notifications.
NotificationsManagerEventsAlphasealed
NotificationsWorkspaceAlphasealedNotificationsWorkspace maintains a registry of NotificationsManagers that facilitate messages across client members in a session.
NotificationsWorkspaceSchemaAlpha

Schema for a NotificationsWorkspace workspace.

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

PresenceBetasealedProvides top-level access to Presence feature set including known Attendees within a session and their custom states kept under StatesWorkspaces.
PresenceEventsBetasealedEvents from Presence.
PresenceWithNotificationsAlphasealedProvides top-level access to Presence feature set including known Attendees within a session and their custom states and notifications kept under StatesWorkspaces and NotificationsWorkspaces.
ProxiedValueAccessorSystemRepresents a value that is accessed via a function call, which may result in no value.
RawValueAccessorSystemRepresents a value that is accessed directly.
StateMapBetasealedMap of local client's values. Modifications are transmitted to all other connected clients.
StatesWorkspaceBetasealed

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.

StatesWorkspaceSchemaBeta

Schema for a StatesWorkspace workspace.

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

Classes

ClassAlertsModifiersDescription
ExperimentalPresenceDODeprecated, AlphasealedBrand for Experimental Presence Data Object.

Types

TypeAliasAlertsModifiersDescription
AccessorSystemUtility type that conditionally represents an accessor type based on the base accessor type.
AttendeeIdBetaA Fluid client session identifier.
AttendeeStatusBeta

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).

ClientConnectionIdBetaA Fluid client connection identifier.
LatestMapRawBetasealedState 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.
LatestMapRawEventsBetasealedEvents from LatestMapRaw.
LatestRawBetasealedState that provides the latest known value from this client to others and read access to their values. All participant clients must provide a value.
LatestRawEventsBetasealedEvents from LatestRaw.
NotificationSubscriptionsAlphasealedRecord of notification subscriptions.
StateSchemaValidatorBetaA validator function that can optionally be provided to do runtime validation of the custom data stored in a presence workspace and managed by a state object.
StatesWorkspaceEntriesBetasealedMap of State objects registered with StatesWorkspace.
StatesWorkspaceEntryBetaSingle entry in StatesWorkspaceSchema or NotificationsWorkspaceSchema.
ValueAccessorSystemUnion of possible accessor types for a value.
WorkspaceAddressBetaUnique address within a session.

Functions

FunctionAlertsReturn TypeDescription
getPresence(fluidContainer)BetaPresenceAcquire a Presence from a Fluid Container
getPresenceAlpha(fluidContainer)AlphaPresenceWithNotificationsAcquire a PresenceWithNotifications from a Fluid Container
getPresenceFromDataStoreContext(context)LegacyPresenceGet Presence from a Fluid Data Store Context
getPresenceViaDataObject(fluidLoadable)Deprecated, AlphaPresenceAcquire Presence from a DataStore based Presence Manager
Notifications(initialSubscriptions)AlphaInternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>Factory for creating a NotificationsManager.

Variables

VariableAlertsModifiersTypeDescription
AttendeeStatusBetareadonly{ readonly Connected: "Connected"; readonly Disconnected: "Disconnected"; }The connection status of the Attendee.
ExperimentalPresenceManagerDeprecated, AlphareadonlySharedObjectKind<IFluidLoadable & ExperimentalPresenceDO>DataStore based Presence Manager that is used as fallback for preferred Container Extension based version requires registration. Export SharedObjectKind for registration.
StateFactoryBetareadonly{ latest: import("./latestValueManager.js").LatestFactory; latestMap: import("./latestMapValueManager.js").LatestMapFactory; }Factory for creating presence State objects.

Namespaces

NamespaceAlertsDescription
InternalTypesSystemCollection of value types that are not intended to be used/imported directly outside of this package.
InternalUtilityTypesSystemCollection of utility types that are not intended to be used/imported directly outside of this package.

Function Details

getPresence

Acquire a Presence from a Fluid Container

This API is provided as a beta preview and may change without notice.

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

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

Signature

getPresence: (fluidContainer: IFluidContainer) => Presence

Parameters

ParameterTypeDescription
fluidContainerIFluidContainerFluid Container to acquire the map from

Returns

the Presence

Return type: Presence

getPresenceAlpha

Acquire a PresenceWithNotifications 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 getPresenceAlpha(fluidContainer: IFluidContainer): PresenceWithNotifications;

Parameters

ParameterTypeDescription
fluidContainerIFluidContainerFluid Container to acquire the map from

Returns

the PresenceWithNotifications

Return type: PresenceWithNotifications

getPresenceFromDataStoreContext

Get Presence from a Fluid Data Store Context

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

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

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

Signature

export declare function getPresenceFromDataStoreContext(context: IFluidDataStoreContext): Presence;

Parameters

ParameterTypeDescription
contextIFluidDataStoreContext

Returns

Return type: Presence

getPresenceViaDataObject

Acquire Presence from a DataStore based Presence Manager

This API is deprecated and will be removed in a future release.
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

ParameterTypeDescription
fluidLoadableExperimentalPresenceDO

Returns

Return type: Presence

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
ParameterConstraintDefaultDescription
TInternalUtilityTypes.NotificationListeners<T>
Keystringstring

Remarks

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

Parameters

ParameterTypeDescription
initialSubscriptionsPartial<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 a beta preview and may change without notice.

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

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 deprecated and will be removed in a future release.
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 a beta preview and may change without notice.

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

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

Signature

StateFactory: {
latest: import("./latestValueManager.js").LatestFactory;
latestMap: import("./latestMapValueManager.js").LatestMapFactory;
}

Type: { latest: import("./latestValueManager.js").LatestFactory; latestMap: import("./latestMapValueManager.js").LatestMapFactory; }

Remarks

Use latest to create a LatestRaw State object. Use latestMap to create a LatestMapRaw State object.