58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
/*
|
|
let mypromise = new Promise((resolve, reject) => {
|
|
let istrue = false;
|
|
if (istrue){
|
|
resolve("resolved");
|
|
} else {
|
|
reject("rejected");
|
|
}
|
|
});
|
|
|
|
|
|
mypromise.then((resolve) => {
|
|
console.log(`resolved: ${resolve}`);
|
|
}).catch((reject) => {
|
|
console.log(`rejected: ${reject}`);
|
|
});
|
|
*/
|
|
|
|
function elso(value){
|
|
return new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
console.log(value);
|
|
resolve(value);
|
|
}, 3000);
|
|
});
|
|
}
|
|
|
|
function masodik(value){
|
|
return new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
console.log(value);
|
|
resolve(value);
|
|
}, 2000);
|
|
});
|
|
}
|
|
|
|
function harmadik(value){
|
|
return new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
console.log(value);
|
|
resolve("Minden lépés teljesítve");
|
|
}, 1000);
|
|
});
|
|
}
|
|
|
|
function asd(){
|
|
elso(1)
|
|
.then((value) => masodik((value + 1)))
|
|
.then((value) => harmadik((value + 1)))
|
|
.then((message) => {console.log(message);});
|
|
}
|
|
|
|
let num = 0;
|
|
setTimeout(() => {console.log("Ez az üzenet 3 másodperc után megjelenik.")}, 3000);
|
|
let ismetles = setInterval(() => {num++;console.log("Ez az üzenet 3 másodpercenként megjelenik.");}, 3000);
|
|
clearInterval(ismetles);
|
|
|