EffectNode class

Low-level node that runs a side-effect function when dependencies change.

This is the graph node behind Effect and Watcher. It tracks dependencies on each run and queues re-runs through the global effect queue.

Prefer Effect in application code; use EffectNode for custom reactive side effects on the core graph.

Example:

final source = SignalNode(0);
final effect = EffectNode(() => print(source.get()));
effect.run();
effect.dispose();
Inheritance

Constructors

EffectNode(void fn(), {bool lazy = false, bool detach = false, JoltDebugOption? debug})
Creates an effect node that invokes fn in a reactive subscriber context.

Properties

deps ↔ Link?
First dependency link in the chain.
getter/setter pairinherited
depsTail ↔ Link?
Last dependency link in the chain.
getter/setter pairinherited
flags int
Reactive flags for this node.
getter/setter pairinherited
fn → void Function()
Side-effect body executed on the initial run and scheduled reruns.
final
hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Whether dispose has been called on this effect.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subs ↔ Link?
First subscriber link in the chain.
getter/setter pairinherited
subsTail ↔ Link?
Last subscriber link in the chain.
getter/setter pairinherited

Methods

cleanup() → void
Runs all registered cleanup callbacks and clears the registry.
inherited
dispose() → void
Disposes this node, unlinks dependencies, and runs cleanup.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyEffect() → void
Enqueues this effect and parent watching effects for execution.
onCleanup(Disposer cleanup) → void
Registers cleanup to run on the next cleanup or dispose.
inherited
run() → void
Runs fn when this node is dirty or has pending dependencies.
toString() String
A string representation of this object.
inherited
track<T>(T fn(), [bool purge = true]) → T
Executes fn while this effect is the active subscriber.
unwatched() → void
Disposes this effect when it loses its last watcher.
override
update() bool
Returns false because effect nodes do not compute cached values.
override

Operators

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