mirror of
https://github.com/xfarrow/blink
synced 2025-04-22 18:07:19 +02:00
update
This commit is contained in:
parent
78464b9525
commit
429a7fadd6
@ -1,6 +1,7 @@
|
|||||||
// https://javascript.info/async-await
|
// https://javascript.info/async-await
|
||||||
|
|
||||||
// A async function always returns a promise. Other values are wrapped in a resolved promise automatically.
|
// A async function always returns a promise. Other values are wrapped in a resolved promise automatically.
|
||||||
|
// Async e Await sono solo "sintassi zuccherina" per rendere l'utilizzo delle Promise più semplice
|
||||||
|
|
||||||
async function f1() {
|
async function f1() {
|
||||||
return 1;
|
return 1;
|
||||||
@ -24,3 +25,15 @@ async function f2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
f2();
|
f2();
|
||||||
|
|
||||||
|
// Domande
|
||||||
|
//
|
||||||
|
// Why await only works in async function in javascript?
|
||||||
|
// https://stackoverflow.com/questions/49640647/why-await-only-works-in-async-function-in-javascript
|
||||||
|
//
|
||||||
|
// Why using async-await
|
||||||
|
// https://stackoverflow.com/questions/42624647/why-use-async-when-i-have-to-use-await
|
||||||
|
//
|
||||||
|
// Si faccia presente che non è possibile creare da zero una funzione asincrona (come
|
||||||
|
// setInterval o fetch)
|
||||||
|
// https://stackoverflow.com/questions/61857274/how-to-create-custom-asynchronous-function-in-javascript
|
||||||
|
11
backend/tutorials/othertests.js
Normal file
11
backend/tutorials/othertests.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
async function exampleAsyncFunction() {
|
||||||
|
console.log('Before await');
|
||||||
|
await new Promise(function(resolve, reject) {
|
||||||
|
setTimeout(() => resolve("done"), 500);
|
||||||
|
}); // Pauses execution here until the promise resolves.
|
||||||
|
console.log('After await');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Start');
|
||||||
|
exampleAsyncFunction();
|
||||||
|
console.log('End');
|
Loading…
x
Reference in New Issue
Block a user