blob: 3a34de99ccb9f6bc8a8e5c483df26fccfd1c2590 [file] [log] [blame]
Idan Amit6187c942018-04-15 19:19:08 +03001import {BasePubSub} from "./base-pubsub";
2
3declare const window: Window;
4
5export class PluginPubSub extends BasePubSub {
6
7 constructor(pluginId: string, parentUrl: string, eventsToWait?: Array<string>) {
8 super(pluginId);
9 this.register('sdc-hub', window.parent, parentUrl);
10 this.subscribe(eventsToWait);
11 }
12
13 public subscribe(eventsToWait?: Array<string>) {
14 const registerData = {
15 pluginId: this.clientId,
16 eventsToWait: eventsToWait || []
17 };
18
19 this.notify('PLUGIN_REGISTER', registerData);
20 }
21
22 public unsubscribe() {
23 const unregisterData = {
24 pluginId: this.clientId
25 };
26
27 this.notify('PLUGIN_UNREGISTER', unregisterData);
28 }
29}