propagate method
Propagates changes through the reactive graph starting from the given link
.
This method:
- Processes subscribers in depth-first order using a stack
- Handles various node states (mutable, watching, dirty, pending)
- Manages recursive checks and propagation flags
- Notifies watchers when changes occur
Implementation
void propagate(Link link) {
Link? next = link.nextSub;
Stack<Link?>? stack;
top:
do {
final sub = link.sub;
int flags = sub.flags;
if ((flags & 60 /* RecursedCheck | Recursed | Rirty | Pending */) == 0) {
sub.flags = flags | 32 /* Pending */;
} else if ((flags & 12 /* RecursedCheck | Recursed */) == 0) {
flags = 0 /* None */;
} else if ((flags & 4 /* RecursedCheck */) == 0) {
sub.flags = (flags & -9 /* ~Recursed */) | 32 /* Pending */;
} else if ((flags & 48 /* Dirty | Pending */) == 0 &&
isValidLink(link, sub)) {
sub.flags = flags | 40 /* Recursed | Pending */;
flags &= 1 /* Mutable */;
} else {
flags = 0 /* None */;
}
if ((flags & 2 /* Watching */) != 0) {
notify(sub);
}
if ((flags & 1 /* Mutable */) != 0) {
final subSubs = sub.subs;
if (subSubs != null) {
final nextSub = (link = subSubs).nextSub;
if (nextSub != null) {
stack = Stack(value: next, prev: stack);
next = nextSub;
}
continue;
}
}
if (next != null) {
link = next;
next = link.nextSub;
continue;
}
while (stack != null) {
final stackValue = stack.value;
stack = stack.prev;
if (stackValue != null) {
link = stackValue;
next = link.nextSub;
continue top;
}
}
break;
} while (true);
}