ReactiveSystem class abstract

Abstract base class for implementing a reactive system.

The ReactiveSystem manages the core operations for maintaining a reactive dependency graph, including linking nodes, propagating changes, and checking for updates.

This class provides the fundamental infrastructure for reactive state management, using a push-pull hybrid approach:

  • Push phase: Changes propagate through the graph to mark affected nodes
  • Pull phase: Values are lazily computed only when accessed

Implementation Requirements

Subclasses must implement three key methods:

  • update: Updates a node's value and returns whether it changed
  • notify: Schedules a node for processing (e.g., queuing an effect)
  • unwatched: Handles cleanup when a node loses all subscribers

Provided Operations

The class provides complete implementations of:

  • link: Establishes dependency relationships between nodes
  • unlink: Removes dependency relationships
  • propagate: Recursively propagates changes through the graph
  • shallowPropagate: Propagates changes to immediate subscribers only
  • checkDirty: Determines if a node needs updating
  • isValidLink: Validates link integrity

Example Implementation

class MyReactiveSystem extends ReactiveSystem {
  @override
  bool update(ReactiveNode node) {
    // Update node value, return true if changed
    return node.updateValue();
  }

  @override
  void notify(ReactiveNode node) {
    // Queue node for processing
    queueEffect(node);
  }

  @override
  void unwatched(ReactiveNode node) {
    // Clean up node when no longer watched
    node.cleanup();
  }
}
Implementers

Constructors

ReactiveSystem()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkDirty(Link link, ReactiveNode sub) bool
Checks if a node is dirty by examining its dependencies.
Validates that a link belongs to a node's dependency list.
Creates or updates a dependency link between two nodes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify(ReactiveNode node) → void
Notifies that a reactive node needs processing.
propagate(Link link) → void
Propagates changes recursively through the dependency graph.
shallowPropagate(Link link) → void
Propagates changes to immediate subscribers only.
toString() String
A string representation of this object.
inherited
Removes a dependency link from the graph.
unwatched(ReactiveNode node) → void
Handles cleanup when a node loses all subscribers.
update(ReactiveNode node) bool
Updates a reactive node's value.

Operators

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