Skip to main content

Async Request Engine Check

Challenge on lesson: Checkpoint: Async Request Engine

Implement three async helpers: 1. createLoader(fetchFn) RETURNS { load, reset }. load(key) calls fetchFn(key) once per key and RETURNS the resulting promise; concurrent and later calls with the same key RETURN THE SAME promise. reset() clears all cached promises (the next load re-fetches). 2. loadDashboard(sources) where sources is an array of zero-argument promise-returning functions. It runs ALL of them concurrently and RETURNS a promise for { loaded, failed }loaded is the array of fulfilled values (in order), failed the array of rejection reasons (in order). It never rejects. 3. withTimeout(promise, ms, fallback) RETURNS a promise that settles with the promise's value if it fulfills within ms, otherwise with fallback. It never rejects.

Difficulty: intermediate

Back to lesson: Checkpoint: Async Request Engine