core library
Core reactive system APIs for advanced usage.
This library exposes the low-level reactive system APIs including reactive nodes, dependency tracking, and the global reactive system. These APIs are typically used by framework implementers or for advanced reactive programming scenarios.
Usage
import 'package:jolt/core.dart';
// Manually trigger propagation algorithm
flush(); // Execute all queued effects
// Work with reactive nodes directly
final node = ReactiveNode(flags: ReactiveFlags.mutable);
link(dependency, subscriber, version);
Classes
- JFinalizer
- A finalizer utility for managing disposers attached to Jolt objects.
- Link
- Link between reactive nodes in the dependency graph.
- ReactiveFlags
- Flags for tracking reactive node state.
- ReactiveNode
- Base class for all reactive nodes in the dependency graph.
-
Stack<
T> - Stack data structure for managing recursive operations.
Properties
- activeScope ↔ EffectScope?
-
getter/setter pair
- activeSub ↔ ReactiveNode?
-
The currently active effect or scope
getter/setter pair
- batchDepth ↔ int
-
The current batch depth
getter/setter pair
- cycle ↔ int
-
The global reactive system
The current cycle number
getter/setter pair
- notifyIndex ↔ int
-
The effect index in queue
getter/setter pair
-
queued
→ List<
EffectBase?> -
The queue of effects to be executed
final
- queuedLength ↔ int
-
The length of the queue of effects to be executed
getter/setter pair
Functions
-
checkDirty(
Link theLink, ReactiveNode sub) → bool - Checks if a node is dirty and needs updating.
-
disposeNode(
ReactiveNode e) → void - Dispose an effect and clean up its dependencies
-
endBatch(
) → void - End a batch update and flush pending effects
-
flushEffects(
) → void - Flush all queued effects
-
getActiveScope(
) → EffectScope? -
getActiveSub(
) → ReactiveNode? -
getBatchDepth(
) → int - Get the current batch depth
-
getComputed<
T> (Computed< T> computed) → T - Get the current value of a computed, updating if necessary
-
getSignal<
T> (Signal< T> signal) → T - Get a signal's value and track dependencies
-
isValidLink(
Link checkLink, ReactiveNode sub) → bool - Checks if a link is still valid for a subscriber.
-
link(
ReactiveNode dep, ReactiveNode sub, int version) → void - Abstract reactive system for managing dependency tracking.
-
notifyComputed<
T> (Computed< T> computed) → void - Force update a computed without changing its value
-
notifyEffect(
JEffect e) → void - Notify a subscriber about changes
-
notifySignal<
T> (ReadonlySignal< T> signal) → void - Force update a signal without changing its value
-
propagate(
Link theLink) → void - Propagates changes through the reactive graph.
-
purgeDeps(
ReactiveNode sub) → void - Purge the dependencies of a reactive node
-
runEffect(
EffectBase e) → void - Run an effect with the given flags
-
setActiveScope(
[EffectScope? scope]) → EffectScope? - Set the currently active subscriber
-
setActiveSub(
[ReactiveNode? sub]) → ReactiveNode? - Set the currently active subscriber
-
setSignal<
T> (Signal< T> signal, T newValue) → T - Set a signal's value and trigger updates
-
shallowPropagate(
Link theLink) → void - Shallow propagates changes without deep recursion.
-
startBatch(
) → void - Start a batch update to defer effect execution
-
trigger(
void fn()) → void - Notify all dependencies about changes
-
unlink(
Link link, [ReactiveNode? sub]) → Link? - Unlinks a dependency from a subscriber.
-
unwatched(
dynamic node) → void - Handle cleanup when a node is no longer watched
-
updateComputed<
T> (Computed< T> computed) → bool - Update the computed value and return true if changed
-
updateNode(
ReactiveNode node) → bool - Update a signal or computed value
-
updateSignal<
T> (Signal< T> signal) → bool - Update a signal's value and return true if changed