didUpdate method

bool didUpdate()

Updates the computed value by re-running the getter.

Clears old dependencies, runs the getter with dependency tracking enabled, and returns whether the value changed.

Returns true if the computed value changed, false otherwise.

Implementation

bool didUpdate() {
  ++cycle;
  depsTail = null;
  flags = ReactiveFlags.mutable | ReactiveFlags.recursedCheck;
  final prevSub = setActiveSub(this);
  try {
    return !identical(currentValue, currentValue = getter(currentValue));
  } finally {
    activeSub = prevSub;
    flags &= -5 /*~ReactiveFlags.recursedCheck*/;
    purgeDeps(this);
  }
}