I´ve been studying Javascript from different sources and I´ve come across this block of code:
function waitForUI() {
return new Promise(function (resolve) {
display.getBoundingClientRect();
requestAnimationFrame(function () {
requestAnimationFrame(resolve);
});
});
}
From what I´ve understood, the promise object can be resolved or rejected and depending on which one something different will happen. But in this case, the promise only has resolve, meaning it can never be rejected? And then there´s a child promise inside the function with only resolve also.. What´s the point then of the promise if it is always going to go through?
I´m not entirely sure how this whole function works so if someone can give me a hint I´d be very grateful, I´ve been thinking about it for a while but can´t get a good answer.
Cheers