Class ListSignal<T>
- Type Parameters:
T- the element type
- All Implemented Interfaces:
Signal<List<ValueSignal<T>>>,Serializable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all entries from this list.Inserts a value at the given index in this list.insertFirst(T value) Inserts a value as the first entry in this list.insertLast(T value) Inserts a value as the last entry in this list.voidremove(ValueSignal<T> entry) Removes the given entry from this list.Methods inherited from class com.vaadin.flow.signals.local.AbstractLocalSignal
assertLockHeld, checkPreconditions, get, getSignalValue, getSignalValueUnsafe, lock, peek, setSignalValue, tryLock, unlock
-
Constructor Details
-
ListSignal
public ListSignal()Creates a new empty list signal.
-
-
Method Details
-
insertFirst
Inserts a value as the first entry in this list.- Parameters:
value- the value to insert- Returns:
- a signal for the inserted entry
-
insertLast
Inserts a value as the last entry in this list.- Parameters:
value- the value to insert- Returns:
- a signal for the inserted entry
-
insertAt
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)orinsertLast(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
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.
-