UNET API - v0.0.0
    Preparing search index...

    Class Realtime

    Realtime: the server tells the app that something changed, the app then asks the ordinary endpoints for the data (so every privacy rule applies as always). One-way Server-Sent Events over fetch with the access token in a header, so the token is never in an address. It reconnects by itself (with a growing pause), asks for a fresh token when the old one is gone, and the server ends a stream before its token would expire: open with reconnected: true is your cue to reload what is on screen. Direct messages and anything private never travel on it.

    const rt = unet.api.realtime({ notifications: true, posts: [post.id] });
    rt.on("notification", () => reloadNotifications());
    rt.on("post", (e) => e.change !== "deleted" && reloadPost(e.postId));
    // later
    rt.update({ notifications: true, posts: [otherPost.id] });
    rt.close();
    Index
    • Type Parameters

      • E extends keyof Handlers

      Parameters

      • event: E
      • fn: Handlers[E]

      Returns () => void

    • Change what is watched; a stream whose topics did not change keeps running.

      Parameters

      Returns void

    • Returns void