디렉터리 페이지에서의 네트워크 호출 최적화

This commit is contained in:
static
2025-12-30 17:21:54 +09:00
parent cdb652cacf
commit 409ae09f4f
25 changed files with 507 additions and 560 deletions

16
src/lib/utils/promise.ts Normal file
View File

@@ -0,0 +1,16 @@
export const monotonicResolve = <T>(
promises: (Promise<T | undefined> | false)[],
callback: (value: T) => void,
) => {
let latestResolvedIndex = -1;
promises.forEach((promise, index) => {
if (!promise) return;
promise.then((value) => {
if (value !== undefined && index > latestResolvedIndex) {
latestResolvedIndex = index;
callback(value);
}
});
});
};