PresetReactiveSystem class

Default implementation of the reactive system for Alien Signals.

PresetReactiveSystem provides the standard reactive behavior used by the alien_signals library. It implements the abstract ReactiveSystem methods to manage signal updates, effect scheduling, and dependency cleanup.

This implementation features:

  • Type-based dispatch: Uses pattern matching to handle different node types
  • Effect batching: Queues effects for efficient batch execution
  • Lazy cleanup: Delays dependency cleanup for mutable nodes until needed
  • Automatic propagation: Handles change propagation through the reactive graph

The system maintains global state including:

Internal Operation

When a signal changes:

  1. The change propagates through propagate to mark dependents
  2. Effects are queued via notify for batch execution
  3. When batch completes, flush executes all queued effects
  4. Each effect's dependencies are tracked during execution

Usage

This class is used internally by the library and is instantiated as a singleton constant:

const system = PresetReactiveSystem();

Most users don't interact with this class directly - they use the high-level API functions like signal(), computed(), and effect() which internally use this system.

Inheritance

Constructors

PresetReactiveSystem()
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.
inherited
Validates that a link belongs to a node's dependency list.
inherited
Creates or updates a dependency link between two nodes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify(ReactiveNode effect) → void
Queues an effect for execution.
override
propagate(Link link) → void
Propagates changes recursively through the dependency graph.
inherited
shallowPropagate(Link link) → void
Propagates changes to immediate subscribers only.
inherited
toString() String
A string representation of this object.
inherited
Removes a dependency link from the graph.
inherited
unwatched(ReactiveNode node) → void
Called when a node no longer has any subscribers.
override
update(ReactiveNode node) bool
Updates a reactive node's value.
override

Operators

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