title: Angular 2 - Substitute for $scope.$apply?
body: <p><code>$scope.$apply</code> will no longer be part of Angular 2. Then how do we let Angular know to update the DOM if any of the bound properties have been changed outside the regular angular execution context?</p>
  
  <p>Taken from <a href="http://blog.mgechev.com/2015/04/06/angular2-first-impressions#no-more-scopeapply" rel="noreferrer">a blog post by Minko Gechev</a>:</p>
  
  <blockquote>
    <p><strong>No more $scope.$apply</strong></p>
    
    <p>But how then AngularJS knows that anything outside it’s execution context has taken a place? Lets think where the changes might come from:</p>
    
    <ul>
    <li>setTimeout</li>
    <li>setInterval</li>
    <li>prompt (yeah, there are people who still use it…)</li>
    <li>XMLHttpRequest</li>
    <li><p>WebSockets</p></li>
    <li><p>…</p></li>
    </ul>
  </blockquote>
  
  <p>For which the answer is:</p>
  
  <p><img src="https://i.stack.imgur.com/jZdgH.png" alt="enter image description here"></p>
  
  <p>I understand that patching the browser built-in javascript functions to notify of any changes to Angular is something that can be done in a relatively safe manner (without introducing subtle bugs) and would be very convenient for the developer. But what about third party APIs (such as <code>jQuery.fadeIn</code>) or if the browser exposes some new asynchronous API which isn't covered? What's the substitute for old <code>$scope.$apply</code>?</p>