From 142be4f767accbed6aafb15e0384c4984b6d0a0d Mon Sep 17 00:00:00 2001 From: "Github Action (authored by pmalacho-mit)" Date: Wed, 24 Jul 2024 16:20:18 -0400 Subject: [PATCH] updating modal to work with doodlebot --- src/svelte/Modal.svelte | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/svelte/Modal.svelte b/src/svelte/Modal.svelte index 27fdfe89ac5..40f724d09f4 100644 --- a/src/svelte/Modal.svelte +++ b/src/svelte/Modal.svelte @@ -23,6 +23,23 @@ type VirtualMachine = _VirtualMachine & { extensionManager: ExtensionManager; }; + + async function untilDefined( + getter: () => T, + delay: number = 100, + ): Promise { + let timeout: Parameters[0]; + let value = getter(); + while (!value) { + await new Promise((resolve) => { + clearTimeout(timeout); + timeout = setTimeout(resolve, delay); + }); + value = getter(); + } + clearTimeout(timeout); + return value; + }