Skip to content

Realtime

Realtime pushes Events, Messages and record changes to Apps and agents as they happen, resumable from a cursor.

Realtime pushes Events, Messages and record changes to connected Apps and agents as they happen. A client that drops resumes from its cursor and misses nothing.

Stream in the SDK

Leaseline declares a Lease Noun. Its manager screen shows each renewal the moment it lands:

TypeScript
import { $ } from 'startup-builder'

const cursor = localStorage.getItem('cursor') ?? undefined

for await (const event of $.stream('Lease.renewed', { cursor })) {
  console.log(event.name, event.data)
  localStorage.setItem('cursor', String(event.seq))
}

Stream to a local server

The CLI forwards each Event, signed, to a local URL, and fires test Events on demand:

Terminal
npx startup-builder listen Offer.subscribed --forward-to http://localhost:3000/hooks
npx startup-builder trigger Offer.subscribed

Rules

RuleDetail
SelectorsA stream reads by Event selector, such as Lease.*, under the caller's Permissions
OrderEvery item carries a sequence number; reconnect with the last one to receive every later item in order
TransportWeb sockets or server-sent events at wss://api.sb/leaseline.app/events/stream
CostA stream is a read and creates no Action per item; open connections count against a Limit per Tenant
PresencePresence and typing reach a Channel's members live and are never stored
AgentsAn agent in a Channel receives its Messages as they arrive; Dashboards refresh live