@mytec: feat: Phase 3.0 Architecture Refactor ✅
Major refactoring of RFCP backend: - Modular propagation models (8 models) - SharedMemoryManager for terrain data - ProcessPoolExecutor parallel processing - WebSocket progress streaming - Building filtering pipeline (351k → 15k) - 82 unit tests Performance: Standard preset 38s → 5s (7.6x speedup) Known issue: Detailed preset timeout (fix in 3.1.0)
This commit is contained in:
30
frontend/src/hooks/useWebSocket.ts
Normal file
30
frontend/src/hooks/useWebSocket.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* React hook wrapping the WebSocket singleton service.
|
||||
*
|
||||
* Provides reactive connection state and progress for UI components.
|
||||
* The actual WS connection is managed by wsService singleton so it
|
||||
* persists across component remounts.
|
||||
*
|
||||
* Usage:
|
||||
* const { connected, progress } = useWebSocket();
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { wsService } from '@/services/websocket.ts';
|
||||
import { useCoverageStore } from '@/store/coverage.ts';
|
||||
|
||||
export function useWebSocket() {
|
||||
const [connected, setConnected] = useState(wsService.connected);
|
||||
const progress = useCoverageStore((s) => s.progress);
|
||||
|
||||
useEffect(() => {
|
||||
// Connect the singleton if not already connected
|
||||
wsService.connect();
|
||||
|
||||
// Subscribe to connection state changes
|
||||
const unsub = wsService.onConnectionChange(setConnected);
|
||||
return unsub;
|
||||
}, []);
|
||||
|
||||
return { connected, progress };
|
||||
}
|
||||
Reference in New Issue
Block a user