ISharedMap Interface
The SharedMap distributed data structure can be used to store key-value pairs.
To use, import via fluid-framework/legacy
.
For more information about our API support guarantees, see here.
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
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.
For more information about our API support guarantees, see here.
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
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.
For more information about our API support guarantees, see here.
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
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