A reactive Signal that holds an Iterable and implements the Iterable interface.
IterableSignal allows you to listen to changes on an iterable collection reactively. It
exposes all standard Iterable properties and methods (like length,
first, map, where, etc.)
directly on the signal itself. Calling these methods inside a reactive context (like an
effect
or computed block) will automatically track them as dependencies.
Example Usage#
import 'package:signals/signals.dart';
void main() {
final items = iterableSignal<int>([1, 2, 3]);
effect(() {
print('Items length: ${items.length}, First: ${items.first}');
}); // Prints: "Items length: 3, First: 1"
// Update the signal by assigning a new iterable
items.value = [10, 20, 30, 40]; // Prints: "Items length: 4, First: 10"
}
Constructors#
View Constructors
IterableSignal(super.value, {IterableSignalOptions? options, @Deprecated('Use options: IterableSignalOptions(autoDispose: ...) instead') bool? autoDispose, @Deprecated('Use options: IterableSignalOptions(name: ...) instead') String? debugLabel})
Creates a IterableSignal with the given value.
Methods#
iterableSignal#
Creates an IterableSignal holding the provided iterable.
This is a convenience function that instantiates an IterableSignal, which delegates all standard Iterable operations reactively and tracks changes.
Example Usage#
import 'package:signals/signals.dart';
final s = iterableSignal([1, 2, 3]);
print(s.length); // 3