vault backup: 2022-07-29 11:00:53

This commit is contained in:
Jet Hughes 2022-07-29 11:00:53 +12:00
parent 56eef6b945
commit 8800ef8ad9
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,33 @@
---
title: "06-async-javascript"
aliases:
tags:
- lecture
- cosc203
---
Async programming allows you to start a potentially long running task have still be able to interact while it it running
general process
- start the task
- return immediately so other tasks can run
- notify us with result when the task is finished
promises
- an object returned by an async function
- represents the current state of the operation
- when the promise is returned to the caller it not always finished
- the promise object has methods to handle the eventual success or failure of the operation
```
const fetchPromise = fetch('https://url.url.json')
fetchPromise
.then((reponse) => {
return response.json();
})
.then((data) => {
console.log(data[0].name)
})
```

View File

@ -36,6 +36,7 @@ tags:
- [02-basic-css](notes/02-basic-css.md)
- [03-more-css](notes/03-more-css.md)
- [05-javascript](notes/05-javascript.md)
-
# Archive