Optimized Event Delivery Pipeline
Architectural Pattern: Event-Driven Cache Invalidation
- REST / Axios Layer: Handles authentication, complex multi-parameter queries, mutations, and complete payload transfers.
- WebSocket Signal Pipe: Delivers ultra-lightweight event messages (e.g., { type: "CALL_LOG_MUTATED", sessionId: "sys_9821" }).
- TanStack Query Invalidation: Listens to incoming signals and invalidates or updates matching query keys directly in the client cache.
1. Connecting WebSockets to Query Cache
src/hooks/useRealtimeCacheSync.ts
2. Displaying Real-Time State in Dashboard Components
src/components/notifications/NotificationList.tsx
Resiliency & Edge-Case Handling
What happens when the WebSocket connection drops unexpectedly?
Should I update state via setQueryData or use query invalidation?
How do you prevent duplicate events during high-frequency server emissions?