To use the RealTimeDataClient, instantiate it with onMessage and onConnect callbacks, then call .connect(). Use the onConnect callback to perform subscriptions via client.subscribe().
import { RealTimeDataClient } from "../src/client";
import { Message } from "../src/model";
const onMessage = (message: Message): void => {
console.log(message.topic, message.type, message.payload);
};
const onConnect = (client: RealTimeDataClient): void => {
// Subscribe to a topic
client.subscribe({
subscriptions: [
{
topic: "comments",
type: "*", // "*" can be used to connect to all the types of the topic
filters: `{"parentEntityID":100,"parentEntityType":"Event"}`,
},
],
});
};
new RealTimeDataClient({ onMessage, onConnect }).connect();