computeWithTracker<T> static method

T computeWithTracker<T>(
  1. T fn(),
  2. void tracker(
    1. ValueCell
    )
)

Compute a cell value using fn while tracking argument cells using tracker.

When the value of an cell is referenced in fn, tracker is called with the referenced cell passed as an argument.

Returns the value computed by fn.

Implementation

static T computeWithTracker<T>(T Function() fn, void Function(ValueCell) tracker) {
  final prevTracker = _onUseArgument;

  try {
    _onUseArgument = tracker;
    return fn();
  }
  finally {
    _onUseArgument = prevTracker;
  }
}