From 38e90fc2e309d394832eee471d4cb9877ae908e2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 17 Nov 2018 13:51:38 +0100 Subject: GameContext: async render loop --- src/util.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/util.ts') diff --git a/src/util.ts b/src/util.ts index 73e30d0..cea404b 100644 --- a/src/util.ts +++ b/src/util.ts @@ -78,3 +78,7 @@ export function get(url: string): Promise { export async function getJSON(url: string): Promise { return JSON.parse((await get(url)).responseText); } + +export function nextAnimationFrame(): Promise { + return new Promise((resolve) => window.requestAnimationFrame(resolve)); +} -- cgit v1.2.3