Class SignalMap<TKey, TVal>

A Map where the state and values are accessible as signals

Type Parameters

  • TKey
  • TVal

Implements

Constructors

Properties

empty: Signal<boolean>

A signal emitting true if the collection is empty

size: Signal<number>

A signal emitting the number of items in the collection

value: Signal<ReadonlyMap<TKey, TVal>>

A signal emitting the inner non-signal map

Methods

  • Add a value to the collection if the key is not in use

    Parameters

    • key: TKey

      The key to use

    • value: TVal

      The value to add

    Returns boolean

    added - Returns true if the value was added

  • Add a value to the collection

    Parameters

    • key: TKey

      The key to use

    • value: TVal

      The value to add

    Returns boolean

    added - Returns true if the value was added or changed

  • Toggle a value in the map

    Parameters

    • key: TKey

      The key to toggle

    • value: TVal

      The value to insert if applicable

    • Optionalstate: boolean

      A forced state (true = always add, false = always delete)

    Returns undefined | boolean

    The applied change (true = item added, false = item removed, undefined = nothing changed)