title: How to use $q's constructor syntax with Angular $http's config.timeout?
body: <p>Since <code>Promise</code> is now officially spec-ed and all, how do I convert the <code>$q.defer()</code> promise creation in the following snippet to use the <code>$q(function (resolve, reject) {})</code> constructor syntax instead?</p>
  
  <pre class="lang-js prettyprint-override"><code>// Cancel any ongoing $http request so that only the most recent $http
  // callback gets invoked
  var canceller;
  function getThing(id) {
    if (canceller) canceller.resolve();
    canceller = $q.defer();
  
    return $http.get('/api/things/' + id, {
      timeout: canceller.promise
    });
  }
  </code></pre>
  
  <p>(Fyi from <a href="https://docs.angularjs.org/api/ng/service/$http#usage" rel="nofollow">$http docs</a>: <code>timeout</code> is "… in milliseconds, or promise that should abort the request when resolved.")</p>