LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

Type: IterableSignal

API reference and details for IterableSignal from signals.dart.

IterableSignal#

Kind: 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"
}
Direct mutation of the items inside the iterable will NOT trigger updates. To reactively mutate collections, use specialized signals like ListSignal, SetSignal, or MapSignal.

Members of IterableSignal#

Member Type Signature Description
IterableSignal constructor dart 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.
== 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: