blob: ec4afb27750911deb8a4b21f76185052361633ad [file] [log] [blame]
import { BasePubSub } from './base-pubsub';
declare const window: Window;
export class PluginPubSub extends BasePubSub {
constructor(pluginId: string, parentUrl: string, eventsToWait?: string[]) {
super(pluginId);
this.register('sdc-hub', window.parent, parentUrl);
this.subscribe(eventsToWait);
}
public subscribe(eventsToWait?: string[]) {
const registerData = {
pluginId: this.clientId,
eventsToWait: eventsToWait || []
};
this.notify('PLUGIN_REGISTER', registerData);
}
public unsubscribe() {
const unregisterData = {
pluginId: this.clientId
};
this.notify('PLUGIN_UNREGISTER', unregisterData);
}
}