[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationLive toggle

Live toggle

The Live / Pause switch of a live page, with the time since the page last read its data.

LiveToggle is the Live / Pause switch of a page declared with live. It shows how long ago the page last read its data ("Updated 12 s ago", counted every second in the browser), and the L key switches it too. The state belongs to the page: every block and table of the page follows it, and the choice is kept per page in the browser.

Live toggle LiveToggle
Connecting to the DMS preview…
Connecting DMS 0.25.8 4 options set
Note

On a page declared without live, the toggle renders nothing. The preview page is not a live page, so the screenshot shows the toggle as it looks on one.

Usage

Place it where you want. A page with a period or live data puts it in a PageToolbar, which draws it beside the PeriodSelector at one size, the same on every page: pageToolbar() adds it as a pill. In a stack of your own:

src/pages/overview.ts ts
import { HStack, Spacer } from "@antelopejs/interface-dms/base/stack";
import { LiveToggle } from "@antelopejs/interface-dms/base/live-toggle";
import { PeriodSelector } from "@antelopejs/interface-dms/base/period-selector";

static toolbar = HStack({ alignment: "center" })
  .child("spacer", Spacer())
  .child("live", LiveToggle({ variant: "pill", missedLabel: "$api.live.new_requests" }))
  .child("period", PeriodSelector({ id: "api" }));

Options

Options of the Live toggle block
OptionTypeDefaultDescription
missedLabel Contentstring–What the paused toggle calls the missed events, given {count}.
align Appearance"left" | "center" | "right"–
showUpdatedAt Appearanceboolean–Shows how long ago the page last read its data.
variant Appearance"segmented" | "pill"–
size Appearance"xs" | "sm" | "md"–
variantLooks like
segmentedTwo segments, Live and Pause. The default.
pillA "Live" pill with a pulsing dot beside a Pause button, and a Resume button while paused.

size (xs, sm, md) scales either variant and its texts. Unset, the toggle takes the size of the PageToolbar holding it, else sm.

While paused

Paused, the toggle says why instead of the time: "Paused · typing in the Tester · 40 new requests · 2 in 5xx". The reason is the hold a component took (or "tab hidden"), the count is the page's missed events named by missedLabel (pluralised on {count}), and the breakdown is what a custom component adds with usePageLive().setMissedDetail().

Next steps

Live pages

Declare live and its refresh rate.

Realtime

Follow the live state from a custom component.