@zedtech/zedkit-live

Poll an endpoint as a live source

Poll on an interval without overlap, back off on failure, abort on stop, and skip unchanged values.

alpha

At a glance

  • Who: Apps whose backend has no push channel, or that need a backup for one.
  • What: Poll on an interval without overlap, back off on failure, abort on stop, and skip unchanged values.
  • Use when: Dashboards and lists that tolerate a few seconds of delay.
  • Avoid when: Sub-second updates; use a push transport.
  • See also: Receive WebSocket messages with reconnect and polling backup

Install

pnpm add @zedtech/zedkit-live

Latest: 0.1.0 (via changesets).

Example

Usage
import { pollingSource } from "@zedtech/zedkit-live";

const jobs = pollingSource({
  intervalMs: 5000,
  poll: (signal) => fetch("/api/jobs", { signal }).then((r) => r.json()),
  isEqual: (a, b) => JSON.stringify(a) === JSON.stringify(b),
});

Wraps: (none)

On this page