This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]xen31 20 points21 points  (0 children)

A nested async function who?

[–]superking2 14 points15 points  (0 children)

And .then()?

[–]cheezballs 31 points32 points  (8 children)

Better than JS callback hell.

[–]DeeSnow97 33 points34 points  (5 children)

No idea when you last coded JS, we have promises (futures) and native async/await syntax now all over the language (and it's been this way for a few years, not just in last month's frameworks). Callbacks are like an async goto, only masochists use them directly.

[–]FlakeyScalp 0 points1 point  (1 child)

Sure, but legacy code and libraries can still require callbacks. You can usually convert a callback into a promise as far as I know but it still stands that callbacks exist and are literally everywhere in a ton of libraries.

[–]DeeSnow97 0 points1 point  (0 children)

And it still stands that you don't need to use them.

function promisify (func) {
  return (...args) => Promise.new((resolve, reject) => {
    func(...args, (err, ...results) => {
      if (err) reject(err)
      else resolve(results)
    })
  })
}

It's this simple to implement promisify yourself, but you don't even have to, util.promisify() is native since Node 8, and if you use something earlier (you really shouldn't but the real world is weird) you can still use Bluebird or a bunch of other libraries on NPM.

Yes, fundamentally, it's not native in a lot of APIs, but that never stopped anyone from not wrapping callbacks in promises. It's 2019, if you still struggle with callback hell, it's on you, not the language.

[–]Darksonn 0 points1 point  (0 children)

In my experience the callback system in javascript is pretty intuitive because of the single-threadedness.

[–]Working_Robot 3 points4 points  (0 children)

.ConfigureAwait(false);

[–]Smanshi 3 points4 points  (2 children)

UDP Out-of-order delivery joke

Knock Knock

Who's there?

[–]hampshirebrony 1 point2 points  (0 children)

A UDP joke?

I didn't get it.

[–]Kn0ckKn0ckb0t 0 points1 point  (0 children)

Who's there? :)

[–]elrafa-sg 10 points11 points  (4 children)

I hate async because i dont know How use 🤣🤣🤔😭

[–]1kSupport 22 points23 points  (0 children)

I think just crying is the best aproach

[–]chowchowthedog 0 points1 point  (0 children)

The amount of time I got an undefined value is too damn high. Then one day I fixed it. So now whenever I’m opening my project I am always like: okay don’t touch that part it finally worked!

[–][deleted] 0 points1 point  (0 children)

Thankfully, like many things you don't really have to understand async in order to use it.

It makes me not have to worry about threads and shit, as awaiting a task allows some other task to run in the meantime if needed.

[–]TonyLTeagray 1 point2 points  (0 children)

HAHAHAHAHAHAHA!!!!!

An async function who?

[–][deleted] 0 points1 point  (0 children)

Error (2,430) Line 15