@bodil/signal
    Preparing search index...

    Class Map<K, V>

    A map which behaves like a signal.

    Any read operation on the map, like Signal.Map.get, Signal.Map.size, or iteration, acts like a Signal.State.get, registering the map as a dependency in any computed signals or effects it's used in. Correspondingly, any write operation to the map will cause all of these dependencies to update as with a Signal.State.set.

    Note that there's no granularity to this access by default: if you read only a single key from the map inside a computed signal, any write to the map, even to a different key, causes the signal to recompute. If you want granularity (and you normally do), use Signal.Map.signal instead of Signal.Map.get.

    Type Parameters

    • K
    • V

    Hierarchy (View Summary)

    Constructors

    • Construct a new map, optionally populating it with the provided key/value pairs.

      Type Parameters

      • K
      • V

      Parameters

      Returns Map<K, V>

    Methods

    • Discard every key/value pair defined in the map, leaving an empty map.

      Returns void

    • Get the value associated with the given key, or, if the key doesn't already exist, call the provided function to create a new value and insert it into the map under the given key.

      Parameters

      • key: K
      • defaultFn: (this: Map<K, V>) => V

      Returns V

    • Test whether the given key is defined in the map.

      Parameters

      • key: K

      Returns boolean

    • Remove the given key from the map, returning its associated value. If the key isn't defined in the map, return None.

      Parameters

      • key: K

      Returns Option<V>

    • Add the given key/value pair to the map, overwriting any previous definitions of the same key.

      Parameters

      • key: K
      • value: V

      Returns this

    • Test whether a value is a Signal.Map.

      Parameters

      • value: unknown

      Returns value is Map<unknown, unknown>