Download packages/client/src/providers/socket-context.ts from QSLY/ghp: direct link, hf CLI and curl.
- Browser
- Download file 469 Bytes
-
https://huggingface.co/spaces/QSLY/ghp/resolve/main/packages/client/src/providers/socket-context.ts
- Command line
-
hf download hf://spaces/QSLY/ghp/packages/client/src/providers/socket-context.ts
-
curl -L -o socket-context.ts https://huggingface.co/spaces/QSLY/ghp/resolve/main/packages/client/src/providers/socket-context.ts
469 Bytes
| import { createContext, useContext } from 'react' | |
| import type { TypedSocket } from '@/lib/socket' | |
| export interface SocketContextValue { | |
| socket: TypedSocket | |
| isConnected: boolean | |
| } | |
| export const SocketContext = createContext<SocketContextValue | null>(null) | |
| export function useSocketContext(): SocketContextValue { | |
| const context = useContext(SocketContext) | |
| if (!context) throw new Error('useSocketContext must be used within SocketProvider') | |
| return context | |
| } | |