Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const subscribePromises = channels.map(channel => {
return subscribe(channel, replayId, streamingEvent => {
this.handleStreamingEvent(streamingEvent);
});
});
// Save susbcriptions and notify success once done
handleSubscribe(event) {
const { channel, replayId } = event.detail;
// Check for duplicate subscription
if (this.subscriptions.some(sub => sub.channel === channel)) {
this.notify(
'error',
'Cannot subscribe',
`Already subscribed to channel ${channel}`
);
return;
}
subscribe(channel, replayId, streamingEvent => {
this.handleStreamingEvent(streamingEvent);
}).then(subscription => {
this.notify(
'success',
'Successfully subscribed',
subscription.channel
);
this.saveSubscription(subscription);
});
}