Async-JS.L.U01-05 (Asynchronous JavaScript)
Async-JS.L.U01-05 (Asynchronous JavaScript)
Async-JS.L.U01-05 (Asynchronous JavaScript)
Asynchronous JavaScript
What is a thread ?
Function is everywhere
Function again
async callback
Easy
Library code
Developer code
What is a Promise?
Promise object representing the eventual completion (fulfil) or failure
(reject) of an asynchronous operation.
There is no todos/0
Promise API:
Promise Usage:
Promise Usage:
chaining .then
3 independent requests
Promise advantages:
1. Callback is guaranted to executed (exactly 1)
2. Built-in error handling mechanism
3. Coding style is OK (not like callback)
Promise disadvantages:
Syntax:
async keyword:
async keyword:
Handle error ?
Not working