ISharedMap Interface
The SharedMap distributed data structure can be used to store key-value pairs.
To use, import via @fluidframework/map/legacy
.
For more information about our API support guarantees, see here.
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
Method | Alerts | Return Type | Description |
---|---|---|---|
get(key) | Alpha |
T | undefined | Retrieves the given key from the map if it exists. |
set(key, value) | Alpha |
this | Sets the value stored at key to the provided value. |
Method Details
get
Retrieves the given key from the map if it exists.
To use, import via @fluidframework/map/alpha
.
For more information about our API support guarantees, see here.
Signature
get<T = any>(key: string): T | undefined;
Type Parameters
Parameter | Default | Description |
---|---|---|
T | any |
Parameters
Parameter | Type | Description |
---|---|---|
key | string | Key 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.
To use, import via @fluidframework/map/alpha
.
For more information about our API support guarantees, see here.
Signature
set<T = unknown>(key: string, value: T): this;
Type Parameters
Parameter | Default | Description |
---|---|---|
T | unknown |
Parameters
Parameter | Type | Description |
---|---|---|
key | string | Key to set |
value | T | Value to set |
Returns
The ISharedMap itself
Return type: this