Realtime Overview
@mountsqli/realtime adds live behavior on top of your data: a Hub of
Channels, PresenceChannel for who’s online, and LiveQuery for query results
that update as data changes.
Pieces
Section titled “Pieces”| Class | Role |
|---|---|
Hub |
owns channels, presence rooms, live queries |
Channel |
pub/sub by name |
PresenceChannel |
tracks members in a room |
LiveQuery |
re-runs a query on change and pushes diffs |
How it fits
Section titled “How it fits”graph TD H[Hub] --> C[Channel: publish/subscribe] H --> P[PresenceChannel: who is here] H --> L[LiveQuery: query + diffs]
Why in-process pub/sub?
Section titled “Why in-process pub/sub?”The Hub is an in-process message bus — fast, no network. The mountsqli dev
server exposes it over SSE (/live/<channel>) so browsers can subscribe.
Best practices
Section titled “Best practices”- Use
LiveQueryfor dashboards that must reflect writes immediately. - Use
PresenceChannelfor “who’s online” without polling. - Unsubscribe (
Unsubscribe) when a client disconnects.
Common mistakes
Section titled “Common mistakes”- Assuming the
Hubspans processes — it’s in-process; use an external bus for multi-instance. - Forgetting to unsubscribe — leaks subscribers.
Related
Section titled “Related”- Presence — track members.
- Live Queries — reactive results.
