Book 6 · Lesson 6.2

TanStack Query and live metrics

  • Read createQuery in Dashboard.tsx
  • Contrast 5s poll vs SSE live feed
  • Handle analyzer unreachable state

Prerequisites: 6.1 · 1.14

Dashboard uses two channels for “live” data:

ChannelAPIUpdates
TanStack QueryGET /api/metrics/summaryStat cards every 5s
EventSource SSE/api/events/streamActivity table rows

TanStack Query

GET /api/metrics/summary · 5s poll

total_events: 42

Polls: 0

SSE live feed

EventSource team_event · Redis pub/sub

Live rows: 0
createQuery(() => ({
  queryKey: ["metrics-summary"],
  queryFn: fetchMetricsSummary,
  refetchInterval: 5000,
}));

See apps/radar/src/api/client.ts.

Teach-back prompt

Why not poll SSE every 5 seconds instead?

Radar metrics poll

Lesson 6.2 check

1. Stat cards refresh via…