notify method
Queues an effect for execution.
Adds the effect and any watching parent effects to the execution queue. Effects are executed together when flush is called or when a batch completes.
This batching mechanism prevents redundant computations and ensures effects run in a consistent order.
Implementation
@override
@pragma('vm:align-loops')
void notify(ReactiveNode effect) {
LinkedEffect? head;
final LinkedEffect tail = effect as LinkedEffect;
do {
(effect as LinkedEffect).nextEffect = head;
head = effect;
effect.flags &= -3 /*~ReactiveFlags.watching*/;
final next = effect.subs?.sub;
if (next == null ||
((effect = next).flags & ReactiveFlags.watching) ==
ReactiveFlags.none) {
break;
}
} while (true);
if (queuedEffectsTail == null) {
queuedEffects = queuedEffectsTail = head;
} else {
queuedEffectsTail!.nextEffect = head;
queuedEffectsTail = tail;
}
}