IterableSignalMixin#
Kind:
class |
Package: package:signals_core
Class: IterableSignalMixin#
A mixin that adds reactive Iterable methods and properties to a Signal
holding an Iterable value.
This mixin delegates all standard Iterable operations (such as length,
first, last, map, where, and any) directly to the underlying
collection, while ensuring that any read operations register a reactive
dependency on the signal.
This mixin only works with signals that have a value type extending Iterable.
Example Usage#
import 'package:signals/signals.dart';
class MyIterableSignal extends Signal<Iterable<int>>
with IterableSignalMixin<int, Iterable<int>> {
MyIterableSignal(super.internalValue);
}
void main() {
final numbers = MyIterableSignal([1, 2, 3]);
// Set up a reactive effect that prints the list size and first element
effect(() {
print('Size: ${numbers.length}, First: ${numbers.first}');
}); // Prints: "Size: 3, First: 1"
// Update the signal value (triggers the effect)
numbers.value = [10, 20, 30, 40]; // Prints: "Size: 4, First: 10"
}
Direct mutation of elements inside the iterable will NOT notify listeners
unless you reassign the value or use a specialized signal class like
ListSignal,
SetSignal, or MapSignal which automatically trigger updates when modified.
Members of IterableSignalMixin#
| Member | Type | Signature | Description |
|---|---|---|---|
| any | method | dart bool any(bool Function(E element) test) | |
| cast | method | dart Iterable | |
| contains | method | dart bool contains(Object? value) | |
| elementAt | method | dart E elementAt(int index) | |
| every | method | dart bool every(bool Function(E element) test) | |
| expand | method | dart Iterable | |
| first | method | dart E first | |
| firstWhere | method | dart E firstWhere(bool Function(E element) test, {E Function()? orElse}) | |
| fold | method | dart R fold(R initialValue, R Function(R previousValue, E element) combine) | |
| followedBy | method | dart Iterable | |
| forEach | method | dart void forEach(void Function(E element) action) | |
| isEmpty | method | dart bool isEmpty | |
| isNotEmpty | method | dart bool isNotEmpty | |
| iterator | method | dart Iterator | |
| join | method | dart String join([String separator = ""]) | |
| last | method | dart E last | |
| lastWhere | method | dart E lastWhere(bool Function(E element) test, {E Function()? orElse}) | |
| length | method | dart int length | |
| map | method | dart Iterable | |
| reduce | method | dart E reduce(E Function(E value, E element) combine) | |
| single | method | dart E single | |
| singleWhere | method | dart E singleWhere(bool Function(E element) test, {E Function()? orElse}) | |
| skip | method | dart Iterable | |
| skipWhile | method | dart Iterable | |
| take | method | dart Iterable | |
| takeWhile | method | dart Iterable | |
| toList | method | dart List | |
| toSet | method | dart Set | |
| where | method | dart Iterable | |
| whereType | method | dart Iterable |
References#
The IterableSignalMixin type is referenced and used in the following pages:
- SetSignalMixin (signals_flutter/mixins)
- ListSignalMixin (signals_flutter/mixins)
- IterableSignalMixin (signals_flutter/mixins)
- signals_flutter
- SetSignalMixin (signals_core/mixins)
- ListSignalMixin (signals_core/mixins)
- IterableSignalMixin (signals_core/mixins)
- signals_core
- SetSignalMixin (signals/mixins)
- ListSignalMixin (signals/mixins)
- IterableSignalMixin (signals/mixins)
- signals