Hacker News new | ask | show | jobs
by loganfsmyth 4044 days ago
Overall, totally agree, just wanted to mention two things.

2) I've always found passing callbacks by name to be very difficult to read/follow, but this is a case where I think ES6 arrow functions will help readability a lot.

    getUserByName('nolan')
        .then(user => getUserAccountById(user.id))
        .then(userAccount => // I got a user account!)
4) Your example isn't quite equivalent, you should be using the 2-param version of .then(), not .then().catch(). In your current code, if your cb threw an exception, it would call it a second time with the error from the first time.