jolt library
Jolt - A reactive system for Dart and Flutter.
Documentation
Basic Usage
import 'package:jolt/jolt.dart';
void main() {
// Create reactive state
final count = Signal(0);
final doubled = Computed(() => count.value * 2);
// React to changes
Effect(() {
print('Count: ${count.value}, Doubled: ${doubled.value}');
});
count.value = 5; // Prints: "Count: 5, Doubled: 10"
}
Classes
-
AsyncError<
T> - Represents the error state of an async operation.
-
AsyncLoading<
T> - Represents the loading state of an async operation.
-
AsyncSignal<
T> - Interface for reactive signals that manage async state transitions.
-
AsyncSource<
T> - Abstract interface for async data sources.
-
AsyncState<
T> - Represents the state of an asynchronous operation.
-
AsyncSuccess<
T> - Represents the success state of an async operation with data.
-
Computed<
T> - Interface for computed reactive values.
- DisposableNode
- Effect
- Interface for reactive effects that run when dependencies change.
- EffectNode
- Interface for effect nodes (Effect, EffectScope, Watcher).
- EffectScope
- Interface for effect scopes that manage the lifecycle of effects.
-
FutureSource<
T> - An async source that wraps a Future.
-
IMutableCollection<
T> - Marker interface for mutable collection types.
-
IterableSignal<
E> - Interface for reactive iterable signals.
-
ListSignal<
E> - Interface for reactive list signals.
-
MapSignal<
K, V> - Interface for reactive map signals.
-
ReadableNode<
T> - Interface for readonly reactive nodes.
-
ReadonlySignal<
T> - A read-only interface for signals that prevents modification.
-
SetSignal<
E> - Interface for reactive set signals.
-
Signal<
T> - A writable interface for signals that allows modification.
-
StreamSource<
T> - An async source that wraps a Stream.
-
Watcher<
T> - Interface for watchers that observe changes to reactive sources.
-
WritableComputed<
T> - Interface for writable computed reactive values.
-
WritableNode<
T> - Interface for writable reactive nodes.
Enums
- DebugNodeOperationType
- Types of operations that can be debugged in the reactive system.
Mixins
- EffectCleanupMixin
-
IterableSignalMixin<
E> - A mixin that provides reactive iterable functionality.
-
ListSignalMixin<
E> - A mixin that provides reactive list functionality.
-
MapSignalMixin<
K, V> - A mixin that provides reactive map functionality.
-
SetSignalMixin<
E> - A mixin that provides reactive set functionality.
Functions
-
batch<
T> (T fn()) → T - Batches multiple reactive updates into a single notification cycle.
-
notifyAll<
T> (T fn()) → T - Executes a function and notifies all dependencies of changes.
-
onEffectCleanup(
Disposer fn, {EffectCleanupMixin? owner}) → void - Registers a cleanup function to be executed when the current effect is disposed or re-run.
-
onScopeDispose(
Disposer fn, {EffectScope? owner}) → void - Registers a cleanup function to be executed when the current effect scope is disposed.
-
trackWithEffect<
T> (T fn(), EffectNode sub, [bool purge = true]) → T - Executes a function with a specific effect node as the active subscriber.
-
untracked<
T> (T fn()) → T - Executes a function without tracking reactive dependencies.
Typedefs
- JoltDebugFn = void Function(DebugNodeOperationType type, ReactiveNode node)
- Function type for debugging reactive system operations.
-
SourcesFn<
T> = T Function() - Function type for providing source values to a watcher.
-
WatcherFn<
T> = void Function(T newValue, T? oldValue) - Function type for handling watcher value changes.
-
WhenFn<
T> = bool Function(T newValue, T oldValue) - Function type for determining when a watcher should trigger.