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:
- Effect queue (queuedEffects/queuedEffectsTail)
- Batch depth tracking (batchDepth)
- Active subscriber tracking (activeSub)
- Version tracking (cycle)
Internal Operation
When a signal changes:
- The change propagates through propagate to mark dependents
- Effects are queued via notify for batch execution
- When batch completes, flush executes all queued effects
- 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
-
- Object
- ReactiveSystem
- PresetReactiveSystem
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
-
isValidLink(
Link checkLink, ReactiveNode sub) → bool -
Validates that a link belongs to a node's dependency list.
inherited
-
link(
ReactiveNode dep, ReactiveNode sub, int version) → void -
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
-
unlink(
Link link, ReactiveNode sub) → Link? -
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