Options
All
  • Public
  • Public/Protected
  • All
Menu

A Replicated Map data type.

remarks

ReplicatedMaps are a mapping of keys (which can be any 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.

Type Parameters

Hierarchy

  • ReplicatedMap

Implements

Index

Constructors

Properties

defaultValue: replicatedentity.ReplicatedMap.DefaultValueCallback<Key, Value> = ...

Generator for default values.

remarks

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.

Methods

  • has(key: Key): boolean
  • Check whether this map contains a value of the given key.

    Parameters

    • key: Key

      The key to check

    Returns boolean

    True if this map contains a value of the given key

  • entries(): IterableIterator<[Key, Value]>
  • Return an (iterable) iterator of the entries of this map.

    Returns IterableIterator<[Key, Value]>

    (iterable) iterator of map entries

  • [iterator](): IterableIterator<[Key, Value]>
  • Return an iterator of the entries of this map.

    Returns IterableIterator<[Key, Value]>

    iterator of map entries

  • values(): IterableIterator<Value>
  • keys(): IterableIterator<Key>
  • get(key: Key): undefined | Value
  • Get the value at the given key.

    Parameters

    • key: Key

      The key to get

    Returns undefined | Value

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

  • toString(): string

Accessors

  • get size(): number
  • get asObject(): {}
  • A representation of this map as an object.

    remarks

    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.

    Returns {}

    • [key: string]: Value

Generated using TypeDoc