1.0.1 • Published 3 years ago

ersrealtime v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

ersrealtime-es6

Client helper library to connect to the realtime server

INSTALL

npm install ersrealtime

EXAMPLE

/// using modules ///
import { onconnect, ondisconnect, subscribe, unsubscribe } from "ersrealtime";

/// using cjs ///
const { onconnect, ondisconnect, subscribe, unsubscribe } = require("ersrealtime");

onconnect(() => {
    console.log("connected to realtime server");
});

ondisconnect(() => {
    console.log("disconnected from realtime server");
});

subscribe(foldername, "upcoming_races", function show_race_id(raceid) {
    console.log(`upcoming race: ${raceid}`);
    // if you want only once:
    // unsubscribe(foldername, "upcoming_races", show_race_id);
});

NOTES

  • there currently isn't a way to clean up connect and disconnect listeners, so the best option here is to create only one of each and route your application around that.