Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created October 20, 2021 10:41
Show Gist options
  • Save velotiotech/c214c301df4c6dff0ccf3957c099e8e2 to your computer and use it in GitHub Desktop.
Save velotiotech/c214c301df4c6dff0ccf3957c099e8e2 to your computer and use it in GitHub Desktop.
async publishMessage(data) {
const subscribers = await this.getSubscribers();
const promises = subscribers.map(async ({ connectionId, subscriptionId }) => {
const TopicSubscriber = new Client(connectionId);
const res = await TopicSubscriber.sendMessage({
id: subscriptionId,
payload: { data },
type: 'data',
});
return res;
});
return Promise.all(promises);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment