読み込みに時間がかかるときにメッセージを出すscript
何らかの処理に時間がかかる場合のみ、別の処理を実行させるmodule
任意の処理を実行できる
読み込み中表示を出せる
code:script.js
export async function loading(process, {onstart, onend, delay = 500} = {}) {
let timer = null;
timer = setTimeout(async () => {
onstart?.();
await process;
onend?.();
}, delay);
const result = await process;
clearTimeout(timer);
return result;
}