Class ListSignal<T>

Type Parameters:
T - the element type
All Implemented Interfaces:
Signal<List<ValueSignal<T>>>, Serializable

public class ListSignal<T> extends AbstractLocalSignal<List<ValueSignal<T>>>
A local list signal that holds a list of writable signals, enabling per-entry reactivity.

Local signals are non-serializable and intended for UI-local state only. They do not participate in clustering and are simpler than shared signals.

Structural mutations (add, remove, clear) trigger list-level dependents. Entry-level mutations (updating an entry's value) only trigger that entry's dependents.

Local list signals can't be used inside signal transactions.

See Also:
  • Constructor Details

    • ListSignal

      public ListSignal()
      Creates a new empty list signal.
  • Method Details

    • insertFirst

      public ValueSignal<T> insertFirst(T value)
      Inserts a value as the first entry in this list.
      Parameters:
      value - the value to insert
      Returns:
      a signal for the inserted entry
    • insertLast

      public ValueSignal<T> insertLast(T value)
      Inserts a value as the last entry in this list.
      Parameters:
      value - the value to insert
      Returns:
      a signal for the inserted entry
    • insertAt

      public ValueSignal<T> insertAt(int index, T value)
      Inserts a value at the given index in this list.

      Note: This method should only be used in non-concurrent cases where the list structure is not being modified by other threads. The index is sensitive to concurrent modifications and may lead to unexpected results if the list is modified between determining the index and calling this method. For concurrent cases, prefer using insertFirst(Object) or insertLast(Object).

      Parameters:
      index - the index at which to insert (0 for first, size() for last)
      value - the value to insert
      Returns:
      a signal for the inserted entry
      Throws:
      IndexOutOfBoundsException - if index is negative or greater than size()
    • remove

      public void remove(ValueSignal<T> entry)
      Removes the given entry from this list. Does nothing if the entry is not in the list.
      Parameters:
      entry - the entry to remove
    • clear

      public void clear()
      Removes all entries from this list.