LogoSignals.dart
Copy Markdown
rodydavis/signals.dart โ˜…9999โ‘‚99

preact_signals

Dart port of Preact.js Signals

Version: 7.0.0

Installation#

dart pub add preact_signals

The preact_signals package is a direct, ultra-high-performance Dart port of Preact.js Signals (v7.0.0). It brings fine-grained reactive programming to Dart VM, command-line interfaces, server environments, and web targets with maximum memory efficiency and minimal execution overhead.

Key Features#

  • โšก High Performance: Built on a highly optimized, double-linked reactive graph that automatically caches derived values.
  • ๐Ÿ“ฆ Memory Efficient: Automatic memory cleanup and garbage collection of inactive nodes.
  • ๐ŸŽฏ Dynamic Dependency Tracking: Automatically tracks which signals are read during execution and re-evaluates effects surgically only when those specific dependencies update.
  • ๐Ÿงช Batching Updates: Group multiple signal updates together into a single transaction so reactions and UI redraws occur only once.

Quick Start#

import 'package:preact_signals/preact_signals.dart';

void main() {
  final count = signal(0);
  final isEven = computed(() => count.value.isEven);

  // Automatically tracks and prints when dependencies update
  final dispose = effect(() {
    print('Count is ${count.value}, isEven: ${isEven.value}');
  });

  count.value = 1;
  count.value = 2;

  dispose();
}

Package Contents#

๐Ÿ› ๏ธ Utilities