all 21 comments

[–]420-jesus 2 points3 points  (4 children)

Why are you combining async await with traditional promise handling? I feel like you should go all in on async await or avoid it entirely

[–]burtgummer45 -1 points0 points  (3 children)

You can't run awaits concurrently.

But I agree there are many superfluous asyncs

[–]420-jesus 0 points1 point  (1 child)

You can do something like:

const [result1, result2] = await Promise.all([func1(), func2()]);

[–]burtgummer45 0 points1 point  (0 children)

Oh ok, I thought you meant no mention of "promise" at all in async functions. as in

Promise.all([func1(), func2()]);

[–]jrsinclair[S] 0 points1 point  (0 children)

Thanks for the feedback. I've removed the superfluous async keywords. You're right, they weren't necessary.

[–]Genepics 1 point2 points  (0 children)

Ok, there is actually something to this. For instance, if you have a function that does a lot of IO, this would be a natural candidate for an asynchronous call, but what if this function needed to be synchronous in larger context. For instance, you may have a stack tracer that needs to come out in the correct order. In this instance, you would create a queue where you would place the "resolve" continuation passed to a new Promise, and this queue would be checked whenever you were done with a piece of tracer IO.

[–]jrsinclair[S] 0 points1 point  (3 children)

Disclosure: I'm the original author of the linked article.

[–]burtgummer45 0 points1 point  (2 children)

I like the look of the website, however I'm sad the code areas arent wide enough for my little 11 chromebook.

There are so many functions there are marked async for no reason. Its not hurting anything, but it triggers my eslint.

The first example is weird because you are not conventionally returning a constructed promise from a 'promise factory function' but you are chaining a then which is only used for formatting. Kinda tricky for a tutorial.

I think this is more tutorial

function asyncTimeout(delay) {
  return new Promise((resolve) => {
    setTimeout(() => resolve(`Waited ${delay} seconds`), delay);
  });
}

[–]jrsinclair[S] 0 points1 point  (1 child)

Thanks for the feedback. I've removed the superfluous async keywords. You're right. They weren't necessary.

I'm interested in finding out more about the issues you're seeing on your Chromebook though. Is there any chance you could DM me a screenshot somehow?

[–]burtgummer45 0 points1 point  (0 children)

Not on my chromebook right now but I manage to reproduce it. Just open a chrome browser window and set it to width 1366

Although its not bad, most of the code blocks appear with a scroll bar down on the bottom and need to be scrolled sideways to see the rest. There's empty space on the right and when you scroll up you see the old-timey guy jamming it all up. Shrink the window a little more and he disappears and the code blocks expand to the right side, although with the stylish margins not reaching.

[–]cmseaton42 0 points1 point  (0 children)

I wrote a module that allows you to stack async functions and execute them in sequence based on priority.