internalRefresh method
bool
internalRefresh(
)
inherited
Implementation
@override
bool internalRefresh() {
flags &= ~NOTIFIED;
if ((flags & RUNNING) != 0) {
return false;
}
// If this computed signal has subscribed to updates from its dependencies
// (TRACKING flag set) and none of them have notified about changes (OUTDATED
// flag not set), then the computed value can't have changed.
if ((flags & (OUTDATED | TRACKING)) == TRACKING) {
return true;
}
flags &= ~OUTDATED;
if (internalGlobalVersion == globalVersion) {
return true;
}
internalGlobalVersion = globalVersion;
// Mark this computed signal running before checking the dependencies for value
// changes, so that the RUNNING flag can be used to notice cyclical dependencies.
flags |= RUNNING;
if (version > 0 && !needsToRecompute()) {
flags &= ~RUNNING;
return true;
}
final prevContext = evalContext;
try {
prepareSources();
evalContext = this;
final val = fn();
if (!_isInitialized ||
(flags & HAS_ERROR) != 0 ||
_internalValue != val ||
version == 0) {
internalValue = val;
flags &= ~HAS_ERROR;
version++;
}
} catch (err, stack) {
error = SignalEffectException(err, stack);
flags |= HAS_ERROR;
version++;
}
evalContext = prevContext;
cleanupSources();
flags &= ~RUNNING;
return true;
}