PliWould/lib/util.ts

15 lines
378 B
TypeScript

function waitForWindow(): Promise<Window> {
return new Promise((resolve) => {
if (typeof window !== 'undefined') {
resolve(window);
} else {
const intervalId = setInterval(() => {
if (typeof window !== 'undefined') {
clearInterval(intervalId);
resolve(window);
}
}, 100);
}
});
}