@zedtech/zedkit-live

Share one live feed between subscribers

Start the transport on the first subscriber, stop it on the last, expose status, and isolate listener errors.

alpha

At a glance

  • Who: Authors of a custom transport (SSE, a vendor channel) and code that consumes any source.
  • What: Start the transport on the first subscriber, stop it on the last, expose status, and isolate listener errors.
  • Use when: Wrapping a transport that is not polling or WebSocket, or typing a function that takes any live source.
  • Avoid when: One-shot fetches; call the endpoint directly.

Install

pnpm add @zedtech/zedkit-live

Latest: 0.1.0 (via changesets).

Example

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

const ticks = createLiveSource<number>((host) => {
  host.setStatus("live");
  const id = setInterval(() => host.emit(Date.now()), 1000);
  return () => clearInterval(id);
});
const stop = ticks.subscribe((t) => console.log(t));

Wraps: (none)

On this page