LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

IterableSignal

A reactive Signal that holds an **Iterable** and implements the **Iterable** interface.

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"
}
Direct mutation of the items inside the iterable will NOT trigger updates. To reactively mutate collections, use specialized signals like [ListSignal](/packages/signals/value/list), [SetSignal](/packages/signals/value/set), or [MapSignal](/packages/signals/value/map).

Constructors#

View Constructors
IterableSignal(super.value, {IterableSignalOptions<E>? 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#

View Methods
bool ==(Object other)
int hashCode