checkDirty method
Checks if a node is dirty and needs updating.
Parameters:
theLink: The link to checksub: The subscriber node
Returns: true if the node is dirty and needs updating
Implementation
bool checkDirty(Link theLink, ReactiveNode sub) {
Link? link = theLink;
Stack<Link?>? stack;
int checkDepth = 0;
bool dirty = false;
top:
do {
final dep = link!.dep;
final flags = dep.flags;
if (sub.flags & 16 /** ReactiveFlags.dirty */ == 16) {
dirty = true;
} else if (flags &
17 /** ReactiveFlags.mutable | ReactiveFlags.dirty */ ==
17) {
if (update(dep)) {
final subs = dep.subs!;
if (subs.nextSub != null) {
shallowPropagate(subs);
}
dirty = true;
}
} else if (flags &
33 /** ReactiveFlags.mutable | ReactiveFlags.pending */ ==
33) {
if (link.nextSub != null || link.prevSub != null) {
stack = Stack(value: link, prev: stack);
}
link = dep.deps!;
sub = dep;
++checkDepth;
continue;
}
if (!dirty) {
final nextDep = link.nextDep;
if (nextDep != null) {
link = nextDep;
continue;
}
}
while (checkDepth-- != 0) {
final firstSub = sub.subs!;
final hasMultipleSubs = firstSub.nextSub != null;
if (hasMultipleSubs) {
link = stack!.value;
stack = stack.prev;
} else {
link = firstSub;
}
if (dirty) {
if (update(sub)) {
if (hasMultipleSubs) {
shallowPropagate(firstSub);
}
sub = link!.sub;
continue;
}
dirty = false;
} else {
sub.flags &= ~32 /* ReactiveFlags.pending */;
}
sub = link!.sub;
final nextDep = link.nextDep;
if (nextDep != null) {
link = nextDep;
continue top;
}
}
return dirty;
} while (true);
}