Skip to main content
Version: v2

SharedObject Class

Helper for implementing ISharedObject with simplified, synchronous summarization and garbage collection.

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 declare abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent>

Extends: SharedObjectCore<TEvent>

Type Parameters​

ParameterConstraintDefaultDescription
TEventISharedObjectEventsISharedObjectEvents

Remarks​

DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.

Constructors​

ConstructorAlertsDescription
(constructor)(id, runtime, attributes, telemetryContextPrefix)BetaConstructs a new instance of the SharedObject class

Properties​

PropertyAlertsModifiersTypeDescription
serializerBetareadonlyIFluidSerializer

Methods​

MethodAlertsReturn TypeDescription
getAttachSummary(fullTree, trackState, telemetryContext)BetaISummaryTreeWithStatsGenerates summary of the channel synchronously. It is called when an attach message for a local channel is generated. In other words, when the channel is being attached to make it visible to other clients.
getGCData(fullGC)BetaIGarbageCollectionDataReturns the GC data for this channel. It contains a list of GC nodes that contains references to other GC nodes.
processGCDataCore(serializer)BetavoidCalls the serializer over all data in this object that reference other GC nodes. Derived classes must override this to provide custom list of references to other GC nodes.
summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext)BetaPromise<ISummaryTreeWithStats>Generates summary of the channel asynchronously. This should not be called where the channel can be modified while summarization is in progress.
summarizeCore(serializer, telemetryContext, incrementalSummaryContext, fullTree)BetaISummaryTreeWithStatsGets a form of the object that can be serialized.

Constructor Details​

(constructor)​

Constructs a new instance of the SharedObject class

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

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

Signature​

constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes,
telemetryContextPrefix: string);

Parameters​

ParameterTypeDescription
idstring
runtimeIFluidDataStoreRuntime
attributesIChannelAttributes
telemetryContextPrefixstring

Property Details​

serializer​

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

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

Signature​

protected get serializer(): IFluidSerializer;

Type: IFluidSerializer

Method Details​

getAttachSummary​

Generates summary of the channel synchronously. It is called when an attach message for a local channel is generated. In other words, when the channel is being attached to make it visible to other clients.

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

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

Signature​

getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;

Remarks​

Note: Since the Attach Summary is generated for local channels when making them visible to remote clients, they don't have any previous summaries to compare against. For this reason, the attach summary cannot contain summary handles (paths to sub-trees or blobs). It can, however, contain @fluidframework/protocol-definitions#ISummaryAttachment (handles to blobs uploaded async via the blob manager).

Parameters​

ParameterModifiersTypeDescription
fullTreeoptionalboolean

A flag indicating whether the attempt should generate a full summary tree without any handles for unchanged subtrees.

Default: false

trackStateoptionalboolean

An optimization for tracking state of objects across summaries. If the state of an object did not change since last successful summary, an @fluidframework/protocol-definitions#ISummaryHandle can be used instead of re-summarizing it. If this is false, the expectation is that you should never send an ISummaryHandle, since you are not expected to track state.

Note: The goal is to remove the trackState and automatically decided whether the handles will be used or not: https://github.com/microsoft/FluidFramework/issues/10455

Default: false

telemetryContextoptionalITelemetryContextSee ITelemetryContext.

Returns​

A summary capturing the current state of the channel.

Return type: ISummaryTreeWithStats

getGCData​

Returns the GC data for this channel. It contains a list of GC nodes that contains references to other GC nodes.

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

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

Signature​

getGCData(fullGC?: boolean): IGarbageCollectionData;

Parameters​

ParameterModifiersTypeDescription
fullGCoptionalbooleantrue to bypass optimizations and force full generation of GC data.

Returns​

Return type: IGarbageCollectionData

processGCDataCore​

Calls the serializer over all data in this object that reference other GC nodes. Derived classes must override this to provide custom list of references to other GC nodes.

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

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

Signature​

protected processGCDataCore(serializer: IFluidSerializer): void;

Remarks​

Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure as a way to visit all the content in this content that may reference other objects via handle.

Parameters​

ParameterTypeDescription
serializerIFluidSerializerThe "serializer" (more like handle visitor) to use. Implementations should ensure that serialize is called on all handles, as the way to visit them.

summarize​

Generates summary of the channel asynchronously. This should not be called where the channel can be modified while summarization is in progress.

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

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

Signature​

summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): Promise<ISummaryTreeWithStats>;

Parameters​

ParameterModifiersTypeDescription
fullTreeoptionalboolean

flag indicating whether the attempt should generate a full summary tree without any handles for unchanged subtrees. It should only be set to true when generating a summary from the entire container.

Default: false

trackStateoptionalboolean

An optimization for tracking state of objects across summaries. If the state of an object did not change since last successful summary, an @fluidframework/protocol-definitions#ISummaryHandle can be used instead of re-summarizing it. If this is false, the expectation is that you should never send an ISummaryHandle, since you are not expected to track state.

Default: false

Note: The goal is to remove the trackState and automatically decided whether the handles will be used or not: https://github.com/microsoft/FluidFramework/issues/10455

telemetryContextoptionalITelemetryContextSee ITelemetryContext.
incrementalSummaryContextoptionalIExperimentalIncrementalSummaryContext

Returns​

A summary capturing the current state of the channel.

Return type: Promise<ISummaryTreeWithStats>

summarizeCore​

Gets a form of the object that can be serialized.

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

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

Signature​

protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext, fullTree?: boolean): ISummaryTreeWithStats;

Parameters​

ParameterModifiersTypeDescription
serializerIFluidSerializer
telemetryContextoptionalITelemetryContext
incrementalSummaryContextoptionalIExperimentalIncrementalSummaryContext
fullTreeoptionalboolean

Returns​

A tree representing the snapshot of the shared object.

Return type: ISummaryTreeWithStats