Promise.allSettled, race & any
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Promise.allSettled() pret të gjitha dhe të tregon cilat patën sukses dhe cilat jo; race() kthehet me të parin që mbaron; any() me të parin që ka sukses.
EnglishEN
Promise.allSettled() waits for all and tells you which succeeded and which failed; race() returns with the first to finish; any() with the first to succeed.
Si ta mendosh
Si garë vrapimi: kush mbërrin i pari, kush e përfundon, kush ra.
Lexoje në anglisht
Like a race: who finishes first, who completes it, who fell.
Shembull kodijavascript
const rez = await Promise.allSettled([merrA(), merrB()]);
rez.forEach(r => console.log(r.status)); // "fulfilled" / "rejected"