skip to Main Content

Javascript – How to dismiss a loading overlay when all promises are settled when promises are continuously added

I have the following class that I'm using to route all my API requests through class PromiseBroker { #promises = {}; #overlayEle = document.getElementById('loading-overlay'); constructor(){ } get promises(){ return this.#promises; } setPromise(key, value){ this.promises[key] = value; this.#overlayEle.classList.remove('d-none'); Promise.allSettled(Object.values(this.promises)).then(results => {…

VIEW QUESTION

Javascript – Nested Promises Execution Order

I was reading about nested promises and encountered this coding challenge in the tutorials. Can someone explain the execution order of this code? new Promise((resolve) => { new Promise((res) => { console.log("c"); resolve(3); res(2); }).then((response) => console.log(response)) }).then((res) => console.log(res));…

VIEW QUESTION
Back To Top
Search