title: Expose promises and custom methods
body: <p>I'm designing an API client with <code>angular</code> and the <code>$http</code> service using a Hypermedia API. Since I have resources that build on top of each other I wanted the client user to be able to do this declaratively:</p>
  
  <pre><code>apiRoot
      .getPeopleRoot()
      .getPerson(1)
      .addJob(apiRoot.getJobsRoot().getRandomJob())
      .updatePerson()
  </code></pre>
  
  <p>But I want to also be able to tap in <code>$then</code> methods to use intermediate results:</p>
  
  <pre><code>$scope.job = apiRoot.getJobsRoot().getRandomJob()
  
  apiRoot.getPeopleRoot().getPerson(1).then(function (person) {
      $scope.person = person
  }).addJob($scope.job).updatePerson()
  </code></pre>
  
  <p>I managed to do each one of these separately by returning the promise or an object that contains the functions to operate with each of these resouces but I'm not sure how to achieve both at the same time, or if it's a good idea.</p>
  
  <p><strong>EDIT</strong>: I managed to progress using the following mixin to my resource objects</p>
  
  <pre><code>function Actualizable() {}
  Actualizable.prototype.actual = function (value) {
    this.realizedValue = value
    return this
  }
  </code></pre>
  
  <p>Then checking if I've resolved the value on each function or calling a promise to actually resolve it. I'm not sure if there's a mechanism to do this with promises still.</p>