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 <[email protected]>
Co-authored-by: zomars <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-05-18 16:25:30 +00:00
1 parent a7f7b29bae
commit 6148e89425
10 files changed
+64 -14

No files matched your search

+10
View File
@@ -369,6 +369,16 @@ export class Cal {
this.actionManager.on(action, callback);
}
off({
action,
callback,
}: {
action: Parameters<SdkActionManager["on"]>[0];
callback: Parameters<SdkActionManager["on"]>[1];
}) {
this.actionManager.off(action, callback);
}
preload({ calLink }: { calLink: string }) {
// eslint-disable-next-line prefer-rest-params
validate(arguments[0], {
@@ -51,6 +51,11 @@ export class SdkActionManager {
window.addEventListener(fullName, callback as EventListener);
}
off(name: string, callback: (arg0: CustomEvent<CustomEventDetail>) => void) {
const fullName = this.getFullActionName(name);
window.removeEventListener(fullName, callback as EventListener);
}
constructor(ns: string | null) {
ns = ns || "";
this.namespace = ns;