Skip to main content

ValueMap Interface

Map of local client's values. Modifications are transmitted to all other connected clients.

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

/** @sealed */
export interface ValueMap<K extends string | number, V>

Type Parameters

Parameter Constraint Description
K string | number
V

Properties

Property Alerts Modifiers Type Description
size Alpha readonly number

Methods

Method Alerts Return Type Description
clear() Alpha void $delete(key)s all elements in the ValueMap.
delete(key) Alpha boolean
forEach(callbackfn, thisArg) Alpha void Executes a provided function once per each key/value pair in the ValueMap, in arbitrary order.
get(key) Alpha InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>> | undefined Returns a specified element from the ValueMap object.
has(key) Alpha boolean
keys() Alpha IterableIterator<K> Returns an iterable of keys in the map.
set(key, value) Alpha this Adds a new element with a specified key and value to the ValueMap. If an element with the same key already exists, the element will be updated. The value will be transmitted to all other connected clients.

Property Details

size

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

readonly size: number;

Type: number

Method Details

clear

$delete(key)s all elements in the ValueMap.

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

clear(): void;

Remarks

This is not yet implemented.

delete

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

delete(key: K): boolean;

Remarks

No entry is fully removed. Instead an undefined placeholder is locally and transmitted to all other clients. For better performance limit the number of deleted entries and reuse keys when possible.

Parameters

Parameter Type Description
key K

Returns

true if an element in the ValueMap existed and has been removed, or false if the element does not exist.

Return type: boolean

forEach

Executes a provided function once per each key/value pair in the ValueMap, in arbitrary order.

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

forEach(callbackfn: (value: InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>, key: K, map: ValueMap<K, V>) => void, thisArg?: unknown): void;

Parameters

Parameter Modifiers Type Description
callbackfn (value: InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>, key: K, map: ValueMap<K, V>) => void
thisArg optional unknown

get

Returns a specified element from the ValueMap object.

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

get(key: K): InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>> | undefined;

Parameters

Parameter Type Description
key K

Returns

Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.

Return type: InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>> | undefined

has

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

has(key: K): boolean;

Parameters

Parameter Type Description
key K

Returns

boolean indicating whether an element with the specified key exists or not.

Return type: boolean

keys

Returns an iterable of keys in the map.

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

keys(): IterableIterator<K>;

Returns

Return type: IterableIterator<K>

set

Adds a new element with a specified key and value to the ValueMap. If an element with the same key already exists, the element will be updated. The value will be transmitted to all other connected clients.

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

set(key: K, value: JsonSerializable<V> & JsonDeserialized<V>): this;

Remarks

Manager assumes ownership of the value and its references. Make a deep clone before setting, if needed. No comparison is done to detect changes; all sets are transmitted.

Parameters

Parameter Type Description
key K
value JsonSerializable<V> & JsonDeserialized<V>

Returns

Return type: this