title: Combining promises and chaining
body: <p>Is there a good design pattern for utilizing promises, while still supporting chaining? For example, let's say that we have something like:</p>
  
  <pre><code>function Foobar() {
    this.foo = function() {
      console.log('foo');
      return this;
    };
  
    this.bar = function () {
      console.log('bar');
      return this;
    };
  }
  
  var foobar = new Foobar();
  foobar.foo().bar();
  </code></pre>
  
  <p>If instead we change the methods to use promises, e.g.</p>
  
  <pre><code>function Foobar() {
    this.foo = function() {
      var self = this;
      return new Promise(function (resolve, reject) {
        console.log('foo');
        resolve(self);
      });
    };
    ...
  }
  </code></pre>
  
  <p>Is there a good way to do something like:</p>
  
  <pre><code>var foobar = new Foobar();
  foobar.foo().bar().then(function () {
    // do something
  });
  </code></pre>