API / base/wait
base/wait
비동기 대기 함수 모음. (await 로 초나 프레임을 기다린다)
Asynchronous wait functions. (await seconds or frames)
예제Example잠깐 기다렸다가 이어 하기Wait a moment, then continue
import { Wait } from "./build/vanilla.js";
const startTime = performance.now();
await Wait.seconds(0.2);
const elapsedMilliseconds = performance.now() - startTime;
console.log(elapsedMilliseconds >= 190);함수Functions
일정 시간 동안 비동기 대기.
Waits asynchronously for a given time.
- secondsnumber
- 기다릴 시간. (초, setTimeout 으로 잰다)Time to wait. (seconds, measured with setTimeout)
반환ReturnsSystem.Promise<void> 시간이 지나면 끝나는 프로미스.A promise that resolves when the time has passed.
짝Counterpart: vanilla-engine seconds
한 프레임 비동기 대기.
Waits asynchronously for one frame.
반환ReturnsSystem.Promise<void> 다음 requestAnimationFrame 이 불리면 끝나는 프로미스. (브라우저에서만, window 가 없으면 거부된다)A promise that resolves on the next requestAnimationFrame. (browser only, rejected if there is no window)
짝Counterpart: vanilla-engine next_frame
예제Example다음 프레임까지 기다리기Wait until the next frame
import { Wait } from "./build/vanilla.js";
await Wait.nextFrame();
await Wait.nextFrame();
console.log("two frames later");