ReactiveGraph class

The core reactive graph engine.

This is the heart of Reacton. It maintains a directed acyclic graph (DAG) of reacton dependencies and handles efficient glitch-free propagation of state changes using a two-phase mark/propagate algorithm.

Two-Phase Algorithm

Phase 1 (Mark): When a writable reacton is set, mark it Dirty. Walk all descendants: mark immediate children as Check, and recursively mark their descendants as Check.

Phase 2 (Propagate): Process nodes in topological order (by level). For Check nodes, verify whether any source actually changed value. If so, recompute. If not, mark Clean without recomputation.

Constructors

ReactiveGraph()

Properties

hashCode int
The hash code for this object.
no setterinherited
nodeCount int
Get the number of nodes in the graph.
no setter
nodes Iterable<GraphNode>
All nodes in the graph.
no setter
onNodeChanged NodeChangeCallback?
Callback invoked when a node's value changes (used by ReactonStore).
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scheduler UpdateScheduler
The update scheduler for batching.
no setter

Methods

contains(ReactonRef ref) bool
Check if a ref is registered.
dispose() → void
Dispose the graph and clear all nodes.
getNode(ReactonRef ref) GraphNode?
Get a node by its ref, or null if not registered.
markDirty(ReactonRef ref) → void
Mark a writable reacton as dirty (Phase 1 entry point).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerComputed(ReadonlyReacton reacton, List<ReactonRef> dependencies) GraphNode
Register a computed (derived) reacton with its dependencies.
registerEffect(ReactonRef ref, List<ReactonRef> dependencies) GraphNode
Register an effect node.
registerWritable(WritableReacton reacton) GraphNode
Register a writable (source) reacton in the graph.
toString() String
A string representation of this object.
inherited
unregister(ReactonRef ref) → void
Unregister a node and remove all its edges.
wouldCreateCycle(ReactonRef source, ReactonRef target) bool
Detect if adding an edge from source to target would create a cycle.

Operators

operator ==(Object other) bool
The equality operator.
inherited