title: How often does the AngularJS digest loop run?
body: <p>When discussing the merits of AngularJS, two-way data binding is often touted as a major benefit of Angular over other JS frameworks.  <a href="https://docs.angularjs.org/guide/scope#integration-with-the-browser-event-loop" rel="nofollow noreferrer">Digging deeper</a>, the documentation suggests this process is done through dirty-checking rather than through event-driven measures. At first, it seems that the digest-loop works by having a method fire off in the background at periodic intervals, checking all the <code>$watch</code>es during each cycle.  However, reading further, it seems that the digest-loop is actually triggered by <code>rootScope.digest()</code>, which in turn is triggered by <code>$.apply</code>, which is in turn triggered by an event(!), such as an <code>onClick</code> event called through <code>ng-click</code>.</p>
  <p>But, how can this be?  I thought Angular <a href="https://stackoverflow.com/questions/9682092/databinding-in-angularjs">doesn't use change listeners</a>. So how does the digest-loop really operate?  <strong>Does Angular automatically kick-off the digest-loop internally, or is the digest-loop triggered by events?</strong>  If the digest-loop is run automatically, how often does it run?</p>
  <hr />
  <p>Some clarification points:</p>
  <ul>
  <li>I'm not asking about how the digest-loop runs when manually binding to changes. In this case, if you want to force a digest loop, you can do so by calling <code>$.apply()</code></li>
  <li>I'm also not asking about how often digest loop runs in response to user events. For example, if ng-model is on an input box, Angular will kick-off a digest loop when a user starts typing.  The confusing part is that in order to know a user was typing, doesn't Angular use an <em>event-based</em> <code>onKeyUp</code> somewhere?</li>
  <li>I already know that there is a limit of 10 cycles max per digest-loop.  My question is less about the number of cycles per digest-loop, but rather the number of digest-loops that run, say, per second.</li>
  <li>Bonus questions: How does the digest-loop relate to the JavaScript event-loop?  Does the JS event loop run periodically in the background?  Is the digest-loop the same thing as the event loop, but only in the &quot;Angular Context&quot;?  Are these totally different ideas?</li>
  </ul>