PubSub

View as Markdown

Access the PubSub API Consumer. You can instantiate a PubSub.Client to subscribe to PubSub events. Please check PubSub Events for the full list of events that a PubSub.Client can subscribe to.

Example

The following example logs the messages sent to the “welcome” channel.

1import { PubSub } from "@signalwire/realtime-api";
2
3const pubSubClient = new PubSub.Client({
4 project: "<project-id>",
5 token: "<api-token>",
6});
7
8pubSubClient.on("message", (m) => console.log(m));
9
10await pubSubClient.subscribe("welcome");

Classes