A Set where the state and values are accessible as signals

Type Parameters

  • T

Implements

Constructors

Properties

array: Signal<T[]>

A signal emitting the values of the set as an array

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<ReadonlySet<T>>

A signal emitting the inner non-signal Set

Methods

  • Add a value to the collection is not already present

    Parameters

    • value: T

      The value to add

    Returns boolean

    added - Returns true if the value was added

  • Add a list of values to the collection is not already present

    Parameters

    • values: T[]

      The values to add

    Returns boolean

    added - Returns true if any value was added

  • Remove a value from the collection

    Parameters

    • value: T

      The key to remove

    Returns boolean

    removed - True if the value existed

  • Remove values from the collection

    Parameters

    • values: T[]

      The values to remove

    Returns boolean

    removed - True if any values were removed

  • Remove all keys not in the whitelist

    Parameters

    • whitelist: undefined | ReadonlySet<T> | T[]

      The keys to keep

    Returns boolean

  • Manually modify the inner collection

    Parameters

    • modify: ((set: Set<T>) => void)
        • (set): void
        • Parameters

          • set: Set<T>

          Returns void

    Returns void

  • Reset the values in the collection to the provided list

    Parameters

    • values: T[] = []

      The values to set

    Returns boolean

    changed - Returns true if the collection changed

  • Toggle a value in the set

    Parameters

    • value: T

      The value to toggle

    • 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)