

ECMAScript 6 promises (2/2): the API - kolodny
http://www.2ality.com/2014/10/es6-promises-api.html

======
angersock
Urgh, why didn't they just follow the conventions set by Q or bluebird?

The fact that I've got to pass a resolver/rejector callback in to the promise
when I make it (isntead of, say, creating a pending promise object and handing
it off to other things to resolve or reject) is really ugly. Like, really,
really ugly.

It's not a horrid syntax, but I much prefer the ability to treat a promise as
just a boring little mutable-once state machine, which I can pass around to
others if needed.

Consider:

    
    
      function qPromise ()
      {
          var ret = Q.defer();
      
          runNodeback( function _roflwaffles( err, result) {
              if (err) {
                  ret.reject(err.toString);
              } else {
                  ret.resolve(result);
              }
          };
      
          return ret.promise;
      }
      
      function ecma6Promise() {
          var ret = new Promise( function _lmaonade(resolve, reject) {
          runNodeback( function _roflwaffles( err, result) {
                  if (err) {
                      ret.reject(err.toString);
                  } else {
                      ret.resolve(result);
                  }
              }; 
          });
      
          return ret;
      }
    

Alright, not so bad...but note: I cannot easily pass that promise down into
helper functions to do more work on it--I have to somehow cram all of my
scoping and functions and nonsense up into that callback at the time of
creation.

Also, how easy is it going to be to swap the parameters of the promise
callback (which came first, without thinking--resolve _or_ reject)?

