Skip to content

Latest commit

 

History

History
115 lines (80 loc) · 2 KB

File metadata and controls

115 lines (80 loc) · 2 KB
title logoImg theme transition highlightTheme slideNumber loop enableMenu enableChalkboard
Async Functions
night
slide
monokai
true
true
false
false
<style> /* Remove the background color and make mongo commands more visible by adding color */ .line.focus{ background:none; font-size: xx-large; color: #5cc4ea; } </style>

Section Overview

This chapter should cover the following:

  1. Async Explaination
  2. Callback
  3. Promises
    • returned promises
    • dealing with rejection
    • multiple promises
  4. Async Await

What is Async?


Most Helpful meme


What is a Promise?


Dealing with Rejection


Async / Await IIFE

Async IFFE {.fragment .current-only data-code-focus=1-1} END of Async IFFE {.fragment .current-only data-code-focus=1-1}

(async ()=>{

})()

(async function() {
  let responses = [];
  responses.push( 
    await get( urls[0] 
    )
  )
})();

Async / Await IIFE

Add Try, Catch, Finally {.fragment .current-only data-code-focus=2-10}

Write your code in Try, Catch, Finally {.fragment .current-only data-code-focus=2-10}

Use Catch to handle the errors and reject Promises{.fragment .current-only data-code-focus=2-10}

Then in the Finally block handle {.fragment .current-only data-code-focus=2-10}

Add Try, Catch, Finally {.fragment .current-only data-code-focus=2-10}

(async ()=> {
  try {
  
  } 
  catch (error) {
     
  }
  finally {

  }
})();