News for hackers. Stuff that matters.
Re:ES6: The features I'm most excited about by seniorsassycat on Sunday July 05, 2015 @11:27PM (#9836569)
I like Jquery's Deferred better then ES6 Promise. Promises lack the `always` callback, they don't have any `progress` events.

The spec on mdn[0] doesn't mention asynchronous `then` or `catch` behavior. If the callback in Jquery `Deferred#then` returns a Deferred that deferred will be returned by `then`.

    // Basic async function, resolves after n milliseconds
    function wait(n) {
      var promise = $.Deferred();
      setTimeout(promise.resolve, n);
      return promise;
    }

    wait(10)
      .then(function() {
        console.log('first');  // prints first after 10 milliseconds
        return wait(10);
      })
      .then(function() {
        console.log('second'); // prints second after 20 milliseconds
        return 'done';
      })
You can 'flip' a failed promise by returning a resolve promise in the fail callback.

    var promise = $.Deferred();
    setTimeout(promise.reject, 100)

    promise.then(null, function () {
      return $.Deferred().resolve([]);
    }).done(function(arg) {
      console.log(arg); // Prints '[]'
    })
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re:ES6: The features I'm most excited about by tracker1 on Monday July 06, 2015 @03:52AM (#9837497)
I don't see the problem...

    function doSomething() {
      return new Promise((resolve,reject)={
        setTimeout(reject,100);
      })
      .catch(() => [])
    }

    doSomething().then((arg) => console.log(arg));
Re:ES6: The features I'm most excited about by seniorsassycat on Monday July 06, 2015 @10:15AM (#9839211)
The problem may have just been the docs. They say .catch and .then can be composed but I didn't see any mention of the behavior.