LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

Type: IterableSignalMixin

API reference and details for IterableSignalMixin from signals.dart.

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#

MemberTypeSignatureDescription
anymethoddart bool any(bool Function(E element) test)
castmethoddart Iterable cast()
containsmethoddart bool contains(Object? value)
elementAtmethoddart E elementAt(int index)
everymethoddart bool every(bool Function(E element) test)
expandmethoddart Iterable expand(Iterable Function(E element) toElements)
firstmethoddart E first
firstWheremethoddart E firstWhere(bool Function(E element) test, {E Function()? orElse})
foldmethoddart R fold(R initialValue, R Function(R previousValue, E element) combine)
followedBymethoddart Iterable followedBy(Iterable other)
forEachmethoddart void forEach(void Function(E element) action)
isEmptymethoddart bool isEmpty
isNotEmptymethoddart bool isNotEmpty
iteratormethoddart Iterator iterator
joinmethoddart String join([String separator = ""])
lastmethoddart E last
lastWheremethoddart E lastWhere(bool Function(E element) test, {E Function()? orElse})
lengthmethoddart int length
mapmethoddart Iterable map(R Function(E e) toElement)
reducemethoddart E reduce(E Function(E value, E element) combine)
singlemethoddart E single
singleWheremethoddart E singleWhere(bool Function(E element) test, {E Function()? orElse})
skipmethoddart Iterable skip(int count)
skipWhilemethoddart Iterable skipWhile(bool Function(E value) test)
takemethoddart Iterable take(int count)
takeWhilemethoddart Iterable takeWhile(bool Function(E value) test)
toListmethoddart List toList({bool growable = true})
toSetmethoddart Set toSet()
wheremethoddart Iterable where(bool Function(E element) test)
whereTypemethoddart Iterable whereType()

References#

The IterableSignalMixin type is referenced and used in the following pages: