title: Alternative to promises of asynchronous callouts?
body: <p>Assume we have a simple front end and (let's assume Angular if it matters) and a back end app. Say the front end app does a <code>get</code> request. Usually the angular repository makes an <code>$http.get</code> request which returns a promise (angular 1) or an observable that can be converted to a promise (angular 2 or 4), and then the repository returns that promise. Then the angular service will look something like</p>
  
  <pre><code>repository.makeTheGetCall().then(function (response) {
    // process response
  }); 
  </code></pre>
  
  <p>This is fine usually.</p>
  
  <p>1) But what if all the logic on the service is dependent on this 1 call? Then we've essentially nested the entirety of the service within a .then clause.</p>
  
  <p>2) Or what if based on the response of the first Get request, we make another request. And based on that response, we make another request, and so on. Then we will have a bunch of then clauses chained.</p>
  
  <p>Neither situations seems that rare, and both result in what appears to be 'ugly' code. Is there any other practice that can be used so to allow asynchronous calls but without having to return promises from the repository layer to the service layer?</p>
  
  <p>Thank you :)</p>