Skip to main content
Version: v2

ISharedMap Interface

The SharedMap distributed data structure can be used to store key-value pairs.

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

To use, import via fluid-framework/legacy.

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

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature​

/** @sealed */
export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any>

Extends: ISharedObject<ISharedMapEvents>, Map<string, any>

Remarks​

SharedMap provides the same API for setting and retrieving values that JavaScript developers are accustomed to with the Map built-in object. However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a FluidObjectHandle.

Note: unlike JavaScript maps, SharedMap does not make any guarantees regarding enumeration order.

For more information, including example usages, see https://fluidframework.com/docs/data-structures/map/.

Methods​

MethodAlertsReturn TypeDescription
get(key)BetaT | undefinedRetrieves the given key from the map if it exists.
set(key, value)BetathisSets the value stored at key to the provided value.

Method Details​

get​

Retrieves the given key from the map if it exists.

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​

get<T = any>(key: string): T | undefined;
Type Parameters​
ParameterDefaultDescription
Tany

Parameters​

ParameterTypeDescription
keystringKey to retrieve from

Returns​

The stored value, or undefined if the key is not set

Return type: T | undefined

set​

Sets the value stored at key to the provided value.

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​

set<T = unknown>(key: string, value: T): this;
Type Parameters​
ParameterDefaultDescription
Tunknown

Parameters​

ParameterTypeDescription
keystringKey to set
valueTValue to set

Returns​

The ISharedMap itself

Return type: this