idol-commons / frontend /src /explorer /model-load-queue.ts
fffiloni's picture
Deploy tested IDOL Commons private development build
26fa2b2 verified
Raw History Blame Contribute Delete
408 Bytes
// GLTF parsing cannot be aborted midway. Let an obsolete parse finish and release
// its resources before starting another download/decoder, instead of overlapping.
let tail:Promise<unknown>=Promise.resolve();
export function queueModelLoad<T>(signal:AbortSignal,task:()=>Promise<T>):Promise<T>{
const run=tail.then(()=>{signal.throwIfAborted();return task();});
tail=run.catch(()=>{});
return run;
}