0

It seems like very useful functionality to simply wait for a Promise to be resolved anywhere one really wants to. It is not obvious to me why it has to be only within a function that itself returns a Promise (marked with async). So what is the really good reason assuming there is one?

I can sort of see that if one is within an event-loop situation that one doesn't want to tie up the event-loop one is dependent upon to actually get the resolution in the first place. But what of languages that are not event-loop based but may have async-await functionality as an add-on (e.g. Python). In such a language it seems to me perfectly fine to tie up the current thread (not co-routine or equivalent) with something like this.

Samantha Atkins
  • 658
  • 4
  • 12
  • Seems like whatever is parsing the script needs to know if a function is asynchronous, and async does that. `await` allows your lines of code to be executed in order but the entire function then becomes asynchronous – inorganik Jan 16 '19 at 22:31
  • `one doesn't want to tie up the event-loop` - fortunately, `await` doesn't do that – Jaromanda X Jan 16 '19 at 22:31
  • I see it for at least code like: someFunction() { return await(someOtherFunction()) In such a case the delayed return is a defacto Promise so why not mark it as such? – Samantha Atkins Jan 16 '19 at 22:33

0 Answers0