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

You know what promises are right?


Yes I do.

Do you use JS or TS currently? We've had async/await since ES2017, it's supported everywhere you want, and there's no reason to see .then() chains anymore outside jokes regarding early 2000's film classic "Dude, Where's My Car?".

Pasting some code and cutting out the boring bits:

  const transaction = await makeTransaction(...);
  const signature = await sendAndConfirmTransaction(...);
  const tokenAccountsByOwner = await getTokenAccountsByOwner(...);
Even back when .then() chaining was used: chaining only existed because that was the only way we had to handle promises, rather than because it was a desirable syntax.


Why would you be so snarky in your answer? Always better to be humble and assume you might be wrong. In this case you are: Nobody chains promises anymore.




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

Search: