Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's a method with a signature like this:

    promise.then(callback)
so:

    var p = doSomethingAsync();
    p.then(function () { alert("hello"); })


I'm assuming they only chose to use this pattern for the purpose of keeping function/method signatures as uniform across the languages as possible? I can't see another advantage to this in JS. Seems like all it's doing is wrapping the call to the actual async operation within the 'then' function, and then probably using the callback as the last argument or storing it somewhere where it will be accessible to the async operation right before it returns.


I saw all of those extra spaces around "then" in the article and assumed the worst. Thanks for clearing that up for me!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: