tick method

  1. @nonVirtual
  2. @protected
void tick()
inherited

Runs a change detection pass on all registered root components.

In development mode, a second change detection cycle is executed in order to ensure that no further changes are detected. If additional changes are picked up, an exception is thrown to warn the user this is bad behavior to rely on for the production application.

Implementation

@nonVirtual
@protected
void tick() {
  if (isDevMode && _runningTick) {
    throw StateError('Change detecion (tick) was called recursively');
  }

  // Checks all components for change detection errors.
  //
  // If at least one occurs, we will re-run looking for the failing component.
  try {
    _current = this;
    _runningTick = true;
    _runTick();
  } catch (e, s) {
    // A crash (uncaught exception) was found. That means at least one
    // directive in the application tree is throwing. We need to re-run
    // change detection to disable offending directives.
    if (!_runTickGuarded()) {
      // Propagate the original exception/stack upwards, with 'DigestTick'
      // keyword. Then application can join tick exception with original
      // exception, which usually named "AppView.detectCrash".
      handleUncaughtException(e, s, 'DigestTick');
    }
    rethrow;
  } finally {
    _current = null;
    _runningTick = false;
    _resetViewErrors();
  }
}