IterableSignal#
class & function |
Package: package:signals_core
Class: IterableSignal#
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"
}
Members of IterableSignal#
| Member | Type | Signature | Description |
|---|---|---|---|
| IterableSignal | constructor |
dart IterableSignal(super.value, {IterableSignalOptions
|
Creates a IterableSignal with the given value. |
| == | method |
dart bool ==(Object other) |
|
| hashCode | method |
dart int hashCode |
Function: iterableSignal#
IterableSignal<T> iterableSignal(Iterable<T> iterable, {IterableSignalOptions<T>? options, @Deprecated('Use options: IterableSignalOptions(autoDispose: ...) instead') bool? autoDispose, @Deprecated('Use options: IterableSignalOptions(name: ...) instead') String? debugLabel})
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
References#
The IterableSignal type is referenced and used in the following pages:
- Signal (signals_flutter/core)
- IterableSignal (signals_flutter/value)
- signals_flutter
- Signal (signals_core/core)
- IterableSignal (signals_core/value)
- signals_core
- Signal (signals/core)
- IterableSignal (signals/value)
- signals
- useIterableSignal (signals_hooks/hooks)