summaryrefslogtreecommitdiffstats
path: root/public/src/app/sdc/plugin-pubsub.ts
diff options
context:
space:
mode:
Diffstat (limited to 'public/src/app/sdc/plugin-pubsub.ts')
-rw-r--r--public/src/app/sdc/plugin-pubsub.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/public/src/app/sdc/plugin-pubsub.ts b/public/src/app/sdc/plugin-pubsub.ts
new file mode 100644
index 0000000..848c7d2
--- /dev/null
+++ b/public/src/app/sdc/plugin-pubsub.ts
@@ -0,0 +1,32 @@
+import { BasePubSub } from './base-pubsub';
+
+declare const window: Window;
+
+export class PluginPubSub extends BasePubSub {
+ constructor(
+ pluginId: string,
+ parentUrl: string,
+ eventsToWait?: Array<string>
+ ) {
+ super(pluginId);
+ this.register('sdc-hub', window.parent, parentUrl);
+ this.subscribe(eventsToWait);
+ }
+
+ public subscribe(eventsToWait?: Array<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);
+ }
+}