generated from CubeCraft-Creations/Tracehound
CUB-195: add useSSE hook and Zustand camera store for live SSE events #2
Reference in New Issue
Block a user
Delete Branch "agent/rex/CUB-195-react-sse-hook"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Creates
useSSEhook connecting to/api/v1/events/streamviaEventSource, with a Zustand store (useCameraStore) for shared camera state.Files
src/hooks/useSSE.ts— React hook that opens an SSE connection, parsescamera_status,camera_online,camera_offline,recording_eventevents, and dispatches them to the camera store. ExposesconnectionState,lastEventTs, andreconnect().src/store/useCameraStore.ts— Zustand store withMap<string, CameraStatus>core state +setCameras,updateCamera,setOffline,setOnline,setRecordingactions. ProvidesgetCameras(),getOnlineCount(),getRecordingCount()derived helpers.src/store/index.ts— Barrel export.src/types/index.ts— AddedCameraStatusandSSEEventinterfaces matching the Go backend.src/hooks/index.ts— Re-exportuseSSEandSSEConnectionState.Validation
npm run lint→ PASSnpm run build→ PASSzustand(which is the lightest state manager at ~1KB)