title: multiple `.then()`s on single angularjs promise -- all use _original_ data
body: <p>I'm writing an angularjs app relying on promises, and though it's working, I wonder if I could do it more optimally.</p>
  
  <p>At the beginning of the code, I'm creating a promise that goes off to fetch some data. When this is done, I want to run several functions that all use this data. The functions are attached at unrelated parts of the app, so I do not know the order in which they're attached to the promise. They do not need to be done in sequence either.</p>
  
  <pre><code>app.service("Fetch", function ($q){
      return function() {
          var def = $q.defer();
          somelibrary.asynccall(function(error, data){ //callback
              if (error) def.reject(error);
              else def.resolve(data);
          });
          return def.promise;
      };
  });
  
  app.controller("ctrl", function ($scope, Fetch) {
      var prom = Fetch();
  
      //somewhere:
      prom.then(function(data){$scope.var1 = data["VAR1"];});
      //somewhere else:
      prom.then(function(data){$scope.var2 = data["VAR2"]});
  });
  </code></pre>
  
  <p>The main disadvantage here is that the later <code>then</code>s are only executed whenever the preceding ones are finished, which is not necessary here. </p>
  
  <p>Also, I need to add <code>return data</code> inside every <code>function(data){...}</code>, otherwise the following <code>then()</code> does not have the <code>data</code> available. </p>
  
  <p>Is there not another way to do this, more apt for this situation? </p>
  
  <hr>
  
  <p>EDIT: as mentioned by @jfriend00, I was mistaken; in fact the 2 functions both run, in parallel, as soon as the promise is successfully resolved, and they are not chained and therefore not dependent on each other. Thanks for your help</p>