aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-ui/src/main/frontend/src/shared/pubsub/plugin-pubsub.ts
blob: 8f99e6596ac1668145d4ebe28feb6e0cd67a05ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {BasePubSub} from 'shared/pubsub/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);
    }
}