@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

main
ts 15 lines 528 Bytes
Raw
1 declare const API_URL: string;
2 declare function useState<T>(): [T | undefined, (value: T) => void];
3 declare function useEffect(effect: () => () => void, deps: unknown[]): void;
4
5 // #region show
6 export function useClicks(code: string) {
7 const [clicks, setClicks] = useState<number>();
8 useEffect(() => {
9 const socket = new WebSocket(`${API_URL}/${code}/live`);
10 socket.onmessage = (event) => setClicks(JSON.parse(event.data).clicks);
11 return () => socket.close();
12 }, [code]);
13 return clicks;
14 }
15 // #endregion show