diff options
author | Idan Amit <ia096e@intl.att.com> | 2018-04-15 19:19:08 +0300 |
---|---|---|
committer | Idan Amit <ia096e@intl.att.com> | 2018-04-15 19:19:08 +0300 |
commit | 6187c942bedebeb2f452ed0856652f90cd5c5772 (patch) | |
tree | 9c3463873e34d9097f2119b9ed35900f6ecab733 /catalog-ui/src/app/models/plugin-pubsub.ts | |
parent | 821b76c6b81ebf96e8fd8340ac5f6ed79f8ed22a (diff) |
New observable notify design in pubsub
Implemented the new subscription mechanism for the pub sub notify function
Change-Id: I5e6484adf1a0413d48b54b55048cda1a59b387ee
Issue-ID: SDC-1178
Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/models/plugin-pubsub.ts')
-rw-r--r-- | catalog-ui/src/app/models/plugin-pubsub.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/catalog-ui/src/app/models/plugin-pubsub.ts b/catalog-ui/src/app/models/plugin-pubsub.ts new file mode 100644 index 0000000000..3a34de99cc --- /dev/null +++ b/catalog-ui/src/app/models/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?: 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); + } +} |