realtime-library
v1.2.0
Published
Realtime client library
Downloads
7
Maintainers
Readme
Example code
import Realtime from "./realtime.mjs";
const realtime = new Realtime({ key: "key1", secret: "secret1", url: "http://localhost:443" });
realtime.onUnsubscribed = (data) => {
console.log(data);
};
realtime.onSubscribed = (data) => {
console.log(data);
realtime.unsubscribe(data.subject);
};
realtime.onConnect = () => {
console.log("connected", realtime.id);
realtime.subscribe("news");
};
realtime.onMessage = (data) => {
console.log(data);
};
realtime.connect();