control flow patterns • You want to be able to execute tasks in : • Series • Parallel • Even implementing array mapping using pure asynchronous functions very hard with plane callbacks
that we don’t know yet • Register an event handler to • Success of an asynchronous operation • Failure of an asynchronous operation • Enable an asynchronous method to return value like a synchronous method
a lot of extra functionality on native ES6 • Promise.mapSeries() • Promise.reduce() • Promise.map() • Promise.Some() • Promise.any() • Promise.each() • Etc …
Inside an async function, we can : • Use await before a function that returns a promise • Await waits for the promise to be resolved • Handle errors with easy and popular mechanism – try / catch • Behind the scenes – asynchronous code
used only inside an Async function • Await is used to wait for a promise • Await cause the execution of the function to stop • Same concept as generators • Help simplify the code to look synchronous • Behind the scenes – asynchronous code
• This is miss-leading as the biggest advantages of Node.js are • Non blocking IO • Parallel IO work with the worker thread pool • You have to remember to work as much in parallel as you can!