Class: ReplicatedMap

akkaserverless.replicatedentity. ReplicatedMap

A Replicated Map data type.

ReplicatedMaps are a mapping of keys (which can be any module:akkaserverless.Serializable) to Replicated Data types. Values of the map are merged together. Elements can be added and removed, however, when an element is removed and then added again, it's possible that the old value will be merged with the new, depending on whether the remove was replicated to all nodes before the add was.

Note that while the map may contain different types of Replicated Data for different keys, a given key may not change its type, and doing so will likely result in the Replicated Data entering a non mergable state, from which it can't recover.


new ReplicatedMap()

Implements:

Members


asObject :Object.<string, module:akkaserverless.replicatedentity.ReplicatedData>

A representation of this map as an object.

All entries whose keys are strings will be properties of this object, and setting any property of the object will insert that property as a key into the map.

Type:

defaultValue :module:akkaserverless.replicatedentity.ReplicatedMap~defaultValueCallback

Generator for default values.

This is invoked by get when the current map has no Replicated Data defined for the key.

If this returns a Replicated Data object, it will be added to the map.

Care should be taken when using this, since it means that the get method can trigger elements to be created. If using default values, the get method should not be used in queries where an empty value for the Replicated Data means the value is not present.

Type:

<readonly> size :number

The number of elements in this map.

Type:
  • number

Methods


clear()

Clear all entries from this map.

Returns:

This map.

Type
module:akkaserverless.replicatedentity.ReplicatedMap

delete(key)

Delete the value at the given key.

Parameters:
Name Type Description
key module:akkaserverless.Serializable

The key to delete.

Returns:

This map.

Type
module:akkaserverless.replicatedentity.ReplicatedMap

entries()

Return an iterator of the entries of this map.

Returns:
Type
Iterator.<Array>

forEach(callback)

Execute the given callback for each element.

Parameters:
Name Type Description
callback module:akkaserverless.replicatedentity.ReplicatedMap~forEachCallback

The callback to handle each element.


get(key)

Get the value at the given key.

Parameters:
Name Type Description
key module:akkaserverless.Serializable

The key to get.

Returns:

The Replicated Data value, or undefined if no value is defined at that key.

Type
undefined | module:akkaserverless.replicatedentity.ReplicatedData

has(key)

Check whether this map contains a value of the given key.

Parameters:
Name Type Description
key module:akkaserverless.Serializable

The key to check.

Returns:

True if this map contains a value of the given key.

Type
boolean

iterator()

Return an iterator of the entries of this map.

Returns:
Type
Iterator.<Array>

keys()

Return an iterator of the keys of this map.

Returns:
Type
Iterator.<module:akkaserverless.Serializable>

set(key, value)

Set the given value for the given key.

Parameters:
Name Type Description
key module:akkaserverless.Serializable

The key to set.

value module:akkaserverless.replicatedentity.ReplicatedData

The value to set.

Returns:

This map.

Type
module:akkaserverless.replicatedentity.ReplicatedMap

values()

Return an iterator of the values of this map.

Returns:
Type
Iterator.<module:akkaserverless.replicatedentity.ReplicatedData>

Type Definitions


defaultValueCallback(key)

Generator for default values.

This is invoked by get when the current map has no Replicated Data defined for the key.

If this returns a Replicated Data object, it will be added to the map.

Care should be taken when using this, since it means that the get method can trigger elements to be created. If using default values, the get method should not be used in queries where an empty value for the Replicated Data means the value is not present.

Parameters:
Name Type Description
key module:akkaserverless.Serializable

The key the default value is being generated for.

Returns:

The default value, or undefined if no default value should be returned.

Type
undefined | module:akkaserverless.replicatedentity.ReplicatedData

forEachCallback(value, key, This)

Callback for handling elements iterated through by module:akkaserverless.replicatedentity.ReplicatedMap#forEach.

Parameters:
Name Type Description
value module:akkaserverless.replicatedentity.ReplicatedData

The Replicated Data value.

key module:akkaserverless.Serializable

The key.

This module:akkaserverless.ReplicatedMap

map.