diff options
Diffstat (limited to 'frontend/app/hooks/useWebSocket.ts')
| -rw-r--r-- | frontend/app/hooks/useWebSocket.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/frontend/app/hooks/useWebSocket.ts b/frontend/app/hooks/useWebSocket.ts new file mode 100644 index 0000000..8fe688f --- /dev/null +++ b/frontend/app/hooks/useWebSocket.ts @@ -0,0 +1,14 @@ +import useWebSocketOriginal, { ReadyState } from "react-use-websocket"; + +export { ReadyState }; + +// Typed version of useWebSocket() hook. +export default function useWebSocket<ReceiveMessage, SendMessage>( + url: string, +): { + sendJsonMessage: (message: SendMessage) => void; + lastJsonMessage: ReceiveMessage; + readyState: ReadyState; +} { + return useWebSocketOriginal(url); +} |
