How to use the lightning/empApi.unsubscribe function in lightning

To help you get started, we’ve selected a few lightning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pozil / streaming-monitor / src / main / default / lwc / streamingMonitor / streamingMonitor.js View on Github external
handleUnsubscribe(event) {
        const { channel } = event.detail;
        let foundIndex = -1;
        const subscription = this.subscriptions.find((sub, index) => {
            if (sub.channel === channel) {
                foundIndex = index;
                return true;
            }
            return false;
        });
        if (foundIndex !== -1) {
            unsubscribe(subscription, response => {
                if (response.successful) {
                    this.notify(
                        'success',
                        'Successfully unsubscribed',
                        channel
                    );
                } else {
                    this.notify('error', 'Failed to unsubscribe', channel);
                    console.error(JSON.stringify(response));
                }
            });
            this.subscriptions.splice(foundIndex, 1);
        }
    }
github pozil / streaming-monitor / src / main / default / lwc / streamingMonitor / streamingMonitor.js View on Github external
this.subscriptions.forEach(subscription => {
            unsubscribe(subscription, response => {
                if (!response.successful) {
                    console.error(JSON.stringify(response));
                }
            });
        });
        this.subscriptions = [];