Message from JavaScript discussions

August 2018

— 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

— 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

— If Promises and async/await doesn’t bug you, you can continue your jouney in JS 😂

— Haha

— It is a great practice for Rust once async syntax will be implemented

— Yep, that's the point, same with callbacks

— There is something weird for me, I'm just doing a mongodb connector, which will occasionally inserting some entries, it seems like if every code out there connect every time for each action to database, is this behaviour correct? isn't more optimal to have an instance of a connection and then use it?

Message permanent page