Kind: Type
Source: src/helper/websocket/index.ts
Part of: Helper
ReadyState for WebSocket
WSReadyState represents the current readiness state of a WebSocket connection. It is used by the WebSocket helper to expose connection status to calling code, such as UI state or message-handling logic.
Definition
ts0 | 1 | 2 | 3
Diagram
mermaidgraph LR Client[Application code] --> Helper[WebSocket helper] Helper --> Socket[WebSocket connection] Socket --> State[WSReadyState] State --> Client
Usage
tsimport type { WSReadyState } from './helper/websocket';
function handleReadyState(state: WSReadyState) {
console.log('WebSocket ready state:', state);
}
const state: WSReadyState = websocket.readyState;
handleReadyState(state);
AI Coding Instructions
- Treat
WSReadyStateas the status contract between the WebSocket helper and its callers. - Keep state checks aligned with the native
WebSocket.readyStatevalue returned by the active socket. - Update consumers when changing the type so UI and connection logic handle every supported state.
- Do not assume a socket is ready to send messages without checking its current ready state.
Was this page helpful?