LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

Type: QueueSignalMixin

API reference and details for QueueSignalMixin from signals.dart.

QueueSignalMixin#

Kind: class  |  Package: package:signals_core

Class: QueueSignalMixin#

A mixin that adds reactive Queue methods and operations to a Signal holding a Queue value.

This mixin delegates all standard Queue operations (such as mutations like add, addAll, addFirst, addLast, removeFirst, removeLast, and clear) to the underlying queue, while ensuring that any reads register a dependency and any mutations automatically trigger reactive updates.

This mixin only works with signals that have a value type extending Queue.

Example Usage#

import 'dart:collection';
import 'package:signals/signals.dart';

class MyQueueSignal extends Signal<Queue<int>>
    with QueueSignalMixin<int, Queue<int>> {
  MyQueueSignal(super.internalValue);
}

void main() {
  final q = Queue<int>()..add(1);
  final signal = MyQueueSignal(q);

  effect(() {
    print('Queue elements: $signal, Length: ${signal.length}');
  }); // Prints: "Queue elements: {1}, Length: 1"

  // Adding to the front of the queue (triggers updates)
  signal.addFirst(0); // Prints: "Queue elements: {0, 1}, Length: 2"

  // Adding to the back of the queue (triggers updates)
  signal.addLast(2); // Prints: "Queue elements: {0, 1, 2}, Length: 3"

  // Removing from the front of the queue (triggers updates)
  final first = signal.removeFirst(); // Prints: "Queue elements: {1, 2}, Length: 2"
}
Since mutations on QueueSignalMixin notify listeners automatically, you do not need to assign signal.value = ... to force updates. Methods like addFirst, addLast, removeFirst, and removeLast take care of notification.

Members of QueueSignalMixin#

MemberTypeSignatureDescription
addmethoddart void add(T value)
addAllmethoddart void addAll(Iterable iterable)
addFirstmethoddart void addFirst(T value)
addLastmethoddart void addLast(T value)
anymethoddart bool any(bool Function(T element) test)
castmethoddart Queue cast()
clearmethoddart void clear()
containsmethoddart bool contains(Object? element)
elementAtmethoddart T elementAt(int index)
everymethoddart bool every(bool Function(T element) test)
expandmethoddart Iterable expand(Iterable Function(T element) toElements)
firstmethoddart T first
firstWheremethoddart T firstWhere(bool Function(T element) test, {T Function()? orElse})
foldmethoddart U fold(U initialValue, U Function(U previousValue, T element) combine)
followedBymethoddart Iterable followedBy(Iterable other)
forEachmethoddart void forEach(void Function(T element) action)
isEmptymethoddart bool isEmpty
isNotEmptymethoddart bool isNotEmpty
iteratormethoddart Iterator iterator
joinmethoddart String join([String separator = ""])
lastmethoddart T last
lastWheremethoddart T lastWhere(bool Function(T element) test, {T Function()? orElse})
lengthmethoddart int length
mapmethoddart Iterable map(U Function(T e) toElement)
reducemethoddart T reduce(T Function(T value, T element) combine)
removemethoddart bool remove(Object? value)
removeFirstmethoddart T removeFirst()
removeLastmethoddart T removeLast()
removeWheremethoddart void removeWhere(bool Function(T element) test)
retainWheremethoddart void retainWhere(bool Function(T element) test)
singlemethoddart T single
singleWheremethoddart T singleWhere(bool Function(T element) test, {T Function()? orElse})
skipmethoddart Iterable skip(int count)
skipWhilemethoddart Iterable skipWhile(bool Function(T value) test)
takemethoddart Iterable take(int count)
takeWhilemethoddart Iterable takeWhile(bool Function(T value) test)
toListmethoddart List toList({bool growable = true})
toSetmethoddart Set toSet()
wheremethoddart Iterable where(bool Function(T element) test)
whereTypemethoddart Iterable whereType()

References#

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