diff options
author | Idan Amit <idan.amit@intl.att.com> | 2019-01-03 18:18:37 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-01-06 09:18:00 +0000 |
commit | bbeb590aaff56ff3364b852f6149b220581b58a1 (patch) | |
tree | c775c17faead68b8b7658516715a41a88476031c /src/plugin-pubsub.ts | |
parent | 3cd900684dc33d5ca07e977df724a0c179a91fa9 (diff) |
Fixed minor issues in sdc-pubusb
Change-Id: I9d667fbb1740376e686824335f2dbae242f8d00c
Issue-ID: SDC-2032
Signed-off-by: Idan Amit <idan.amit@intl.att.com>
Diffstat (limited to 'src/plugin-pubsub.ts')
-rw-r--r-- | src/plugin-pubsub.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/plugin-pubsub.ts b/src/plugin-pubsub.ts new file mode 100644 index 0000000..ec4afb2 --- /dev/null +++ b/src/plugin-pubsub.ts @@ -0,0 +1,29 @@ +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); + } +} |