Message from JavaScript discussions

August 2018

— I know in web applications is full of middlewares but I'm just doing a tiny rest client expecting to be attached to a Telegram API

Message permanent page

— 

You can store promises of those operations in variables. And when you really need them you can use await in an async function.

— So async/await will be propagated always, right?

— I dont know what do you mean by propagated

— The return from an async function would always be a promise, if that's what you mean

— So you can store it

— Meaning that in order to use a promise if I do await, I need to be in an async function. Anyway I can also use then

Message permanent page

— I'm getting the point, different paradigm but great anyway

— If you use then, you will only can have the result in the scope of the callback of that then. Even if you use a “global” scoped variable you have no guarantee the callback have finished. await will “pause” your async function until that promise resolves. Then you can use the value inside the async function. But yeah, async functions are Promises.

Message permanent page

— Gotcha, thanks

— What I meant is once you use a promise, you will be carrying the promise until the end :D

— So yes, as you said