diff options
author | Idan Amit <ia096e@intl.att.com> | 2018-07-19 12:05:50 +0300 |
---|---|---|
committer | Idan Amit <ia096e@intl.att.com> | 2018-07-19 13:30:34 +0300 |
commit | a2c544de543343ad4135f0419f1548ed1cf502cb (patch) | |
tree | a89bfc6b50a322a2411fd4941c3afe1f57474471 /lib/plugin-pubsub.ts | |
parent | 5c580897a8a46398876dd40ae58758663eed52d9 (diff) |
sdc-pubsub first commit
Committed sdc-pubsub code for the first time to LF repo
Change-Id: I1e26f7fe8b2f1747169e3101e0705d1c89d3f56b
Issue-ID: SDC-1537
Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'lib/plugin-pubsub.ts')
-rw-r--r-- | lib/plugin-pubsub.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/plugin-pubsub.ts b/lib/plugin-pubsub.ts new file mode 100644 index 0000000..3a34de9 --- /dev/null +++ b/lib/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); + } +} |