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