track<T> method
Executes fn while this effect is the active subscriber.
Returns the result of fn. When purge is true (default), dependency
links from prior runs are cleared before and after fn so only
dependencies read inside fn remain.
Implementation
T track<T>(T Function() fn, [bool purge = true]) {
if (purge) {
++cycle;
depsTail = null;
}
final prevSub = setActiveSub(this);
try {
return fn();
} finally {
setActiveSub(prevSub);
if (purge) {
flags = ReactiveFlags.watching;
purgeDeps(this);
}
}
}