RyanHirsch
04/23/2022, 2:31 PMRyanHirsch
04/23/2022, 2:33 PMgaryaustin
04/23/2022, 2:39 PMRyanHirsch
04/23/2022, 2:43 PMts
client.connect();
client.onOpen(() => console.log("Socket opened."));
client.onClose(() => console.log("Socket closed."));
client.onError((e) => console.log("Socket error", e.message));
// Listen to events on a table, using the format `realtime:{SCHEMA}:{TABLE}`
var databaseChanges = client.channel("realtime:*");
databaseChanges.on("*", (e) => console.log(`${e.table}:${e.type}`));
databaseChanges.on("INSERT", (e) => console.log(e));
databaseChanges.on("UPDATE", (e) => console.log(e.table));
databaseChanges.on("DELETE", (e) => console.log(e));
databaseChanges.subscribe();
async function gracefulExit() {
console.log("Stopping...");
await client.disconnect();
}
process.on("SIGINT", gracefulExit);
process.on("SIGTERM", gracefulExit);
garyaustin
04/23/2022, 2:52 PMRyanHirsch
04/23/2022, 2:52 PMRyanHirsch
04/23/2022, 2:52 PMgaryaustin
04/23/2022, 2:58 PMRyanHirsch
04/23/2022, 2:59 PMRyanHirsch
04/23/2022, 2:59 PMRyanHirsch
04/23/2022, 3:01 PMts
var flipChanges = client.channel("realtime:public:Flip");
flipChanges.on("*", (e) => console.log(`${e.table}:${e.type}`));
flipChanges.subscribe();
garyaustin
04/23/2022, 3:03 PMRyanHirsch
04/23/2022, 3:04 PMgaryaustin
04/23/2022, 3:04 PMRyanHirsch
04/23/2022, 3:04 PMProfile
RyanHirsch
04/23/2022, 3:05 PMgaryaustin
04/23/2022, 3:06 PMgaryaustin
04/23/2022, 3:06 PMRyanHirsch
04/23/2022, 3:07 PMgaryaustin
04/23/2022, 3:08 PMgaryaustin
04/23/2022, 3:09 PMgaryaustin
04/23/2022, 3:10 PMRyanHirsch
04/23/2022, 3:13 PMRyanHirsch
04/23/2022, 3:24 PM