trackDerivation<T> method

T? trackDerivation<T>(
  1. Derivation d,
  2. T fn()
)

Implementation

T? trackDerivation<T>(Derivation d, T Function() fn) {
  final prevDerivation = _startTracking(d);
  T? result;

  try {
    if (config.disableErrorBoundaries == true) {
      result = fn();
    } else {
      try {
        result = fn();
        d._errorValue = null;
      } on Object catch (e, s) {
        d._errorValue = MobXCaughtException(e, stackTrace: s);
      }
    }
  } finally {
    _endTracking(d, prevDerivation);
  }
  return result;
}