PliWould/lib/util.ts

15 lines
378 B
TypeScript
Raw Normal View History

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);
}
});
}