Files
cal.diy/packages/embeds/embed-react/src/index.ts
T

18 lines
390 B
TypeScript

import { CalWindow } from "@calcom/embed-core";
import Cal from "./Cal";
export const getCalApi = (): Promise<CalWindow["Cal"]> =>
new Promise(function tryReadingFromWindow(resolve) {
const api = (window as CalWindow).Cal;
if (!api) {
setTimeout(() => {
tryReadingFromWindow(resolve);
}, 50);
return;
}
resolve(api);
});
export default Cal;