jolt 4.0.0-dev.1
jolt: ^4.0.0-dev.1 copied to clipboard
A lightweight, high-performance reactive signals library for Dart/Flutter with fine-grained updates and intelligent resource management.
Jolt #
Fine-grained reactive state for Dart and Flutter.
Jolt gives you three small building blocks: Signal for writable state,
Computed for values derived from state, and Effect for work that reacts to
changes. No code generation, no widget context, no manual subscription wiring.
A Small Example #
import 'package:jolt/jolt.dart';
final query = Signal('');
final documents = Signal([
'Signals store state',
'Computed values derive state',
'Effects run after state changes',
]);
final results = Computed(() {
final text = query.value.trim().toLowerCase();
if (text.isEmpty) return documents.value;
return documents.value
.where((document) => document.toLowerCase().contains(text))
.toList();
});
final resultCountEffect = Effect(() {
print('${results.value.length} result(s) for "${query.value}"');
});
query.value = 'state';
query.value = 'effect';
resultCountEffect.dispose();
Change a signal, and the values that read it update automatically. Derived values stay in sync without being stored twice. Effects are explicit objects, so the code that starts an effect also decides when to dispose it.
Why Jolt? #
- Plain Dart first: keep state in normal classes, then connect it to Flutter when the UI needs it.
- Fine-grained updates: reactions track the exact values they read.
- Derived state without bookkeeping: compute
filteredItems,isValid, orsummaryTextfrom current state instead of syncing extra fields. - Clear lifecycle: dispose an
Effect/Watcherdirectly, or group related reactions in anEffectScope. - Practical tools included: batching, watchers, streams, async state, and persistence helpers.
Packages #
Use jolt for core reactive state. Add a sibling package only when you need a
specific integration:
jolt_flutterfor Flutter rebuilds from Jolt reads.jolt_setupfor setup-style widget logic with cleanup.jolt_hooksfor projects usingflutter_hooks.jolt_surgefor a container-style layer on top of Jolt.
Learn More #
Start with the Quick Start or jump to the API reference.
License #
MIT