Embed React improvements (#2782)

* Add off support. Add getApi export.

* Add publish command

* Add embed-snippet in prod deps

* Update README

* Update package.json

Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Hariom Balhara
2022-05-18 16:25:30 +00:00
committed by GitHub
co-authored by Bailey Pumfleet zomars kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent a7f7b29bae
commit 6148e89425
10 changed files with 64 additions and 14 deletions
+14
View File
@@ -1,3 +1,17 @@
import { CalWindow } from "@calcom/embed-snippet";
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;