A Set where the state and values can be observed

Type Parameters

  • T

Implements

Constructors

Properties

array$: Observable<T[]>

An observable emitting the values of the set as an array

empty$: Observable<boolean>

An observable emitting true if the collection is empty

itemAdded$: Observable<T>

Emits for every item that is added to the set

itemDelta$: Observable<ObservableSetItemChange<T>>

Emits for every item that is added/removed in the list, including the changes from an empty set to the current state

itemRemoved$: Observable<T>

Emits for every item that is removed from the set

itemUpdates$: Observable<ObservableSetItemChange<T>>

Emits for every item that is added/removed in the set

size$: Observable<number>

An observable emitting the number of items in the collection

updates$: Observable<ReadonlySet<T>>

Emits all updates to the set

value$: Observable<ReadonlySet<T>>

An observable emitting the inner non-observable Set

Accessors

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)