ListSignal<E> class
============================================================================ COLLECTION SIGNALS
Signal for List with convenient mutation methods.
ListSignal provides reactive list operations while maintaining immutability. Each mutation creates a new list instance to trigger updates.
Basic Usage
final items = ListSignal<String>(['A', 'B']);
// Add item
items.add('C'); // Emits ['A', 'B', 'C']
// Remove item
items.remove('A'); // Emits ['B', 'C']
// Update item
items.replaceAt(0, 'Z'); // Emits ['Z', 'C']
Binding to UI
Slot(
connect: items,
to: (context, list) {
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) => Text(list[index]),
);
},
)
- Inheritance
-
- Object
- NeuronAtom<
List< E> > - Signal<
List< E> > - ListSignal
Constructors
-
ListSignal(List<
E> initial, {String? debugLabel, bool equals(List<E> a, List<E> b)?, List<E> guard(List<E> current, List<E> next)?, VoidCallback? onListen, VoidCallback? onCancel})
Properties
- debugLabel → String?
-
Debug label for identification in DevTools.
finalinherited
-
equals
→ bool Function(List<
E> a, List<E> b)? -
Custom equality function to determine if value has changed.
finalinherited
-
guard
→ List<
E> Function(List<E> current, List<E> next)? -
Value guard/transformer called before setting a new value.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether this atom has any listeners.
no setterinherited
-
initialValue
→ List<
E> -
The initial value of the atom.
no setterinherited
- isDisposed → bool
-
Whether this atom has been disposed.
no setterinherited
- isEmpty → bool
-
Check if list is empty.
no setter
- isNotEmpty → bool
-
Check if list is not empty.
no setter
- length → int
-
Get length of list.
no setter
- onCancel → VoidCallback?
-
Callback invoked when the last listener unsubscribes.
finalinherited
- onListen → VoidCallback?
-
Callback invoked when the first listener subscribes.
finalinherited
-
previousValue
→ List<
E> ? -
The previous value of the atom (before the last change).
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
List< E> > -
A broadcast stream of value changes.
no setterinherited
-
val
→ List<
E> -
Short alias for the current value.
no setterinherited
-
value
↔ List<
E> -
Override value getter to support dependency tracking for Computed.
getter/setter pairinherited
Methods
-
add(
E item) → void - Add an item to the list.
-
addAll(
Iterable< E> items) → void - Add multiple items to the list.
-
addListener(
VoidCallback listener) → void -
Adds a listener to be called when the value changes.
inherited
-
clear(
) → void - Clear all items.
-
dispose(
) → void -
Disposes the atom, removing all listeners.
inherited
-
emit(
List< E> val) → void -
Assigns a new value and notifies listeners if the value changed.
inherited
-
filter(
bool test(E)) → void - Filter items that match condition.
-
insert(
int index, E item) → void - Insert item at index.
-
map<
T> (T transform(E)) → void - Map items to new type and emit.
-
mutate(
void mutator(List< E> list)) → void - Mutate the list in-place and notify listeners.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Manually notifies all listeners.
inherited
-
onActive(
) → void -
Called when the first listener is added.
inherited
-
onInactive(
) → void -
Called when the last listener is removed.
inherited
-
remove(
E item) → bool - Remove an item from the list.
-
removeAt(
int index) → E - Remove item at index.
-
removeListener(
VoidCallback listener) → void -
Removes a previously added listener.
inherited
-
replaceAt(
int index, E item) → void - Replace item at index.
-
reset(
) → void -
Resets the atom to its initial value.
inherited
-
reverse(
) → void - Reverse the list.
-
select<
R> (R selector(List< E> value)) → NeuronAtom<R> -
Creates a new atom that selects a part of this atom's value.
inherited
-
shuffle(
[int? seed]) → void - Shuffle the list.
-
sort(
[int compare(E a, E b)?]) → void - Sort list with optional comparator.
-
subscribe(
VoidCallback listener) → VoidCallback -
Adds a listener and returns a callback that cancels the subscription when called.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → E - Access item by index.