Show which slide show hours is fetched

This commit is contained in:
Guntis Smaukstelis
2025-02-23 20:21:11 +02:00
parent 6c9f544342
commit b6cc4a4b24
7 changed files with 65 additions and 25 deletions
+19
View File
@@ -0,0 +1,19 @@
export async function handleProgressivePromises<T>(
promises: Promise<T>[],
onProgress: (result: T) => void,
): Promise<(T | undefined)[]> {
const allPromises = promises.map(async promise => {
try {
const result = await promise;
onProgress(result)
return result
} catch (error) {
return undefined
}
})
const results = await Promise.allSettled(allPromises)
return results.map(result =>
result.status === 'fulfilled' ? result.value : undefined
)
}