Files
yaak/apps/yaak-proxy/hooks/useRpcEvent.ts
Gregory Schier 7314aedc71 Merge main into proxy branch (formatting and docs)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 12:09:59 -07:00

16 lines
433 B
TypeScript

import type { RpcEventSchema } from "@yaakapp-internal/proxy-lib";
import { useEffect } from "react";
import { listen } from "../lib/rpc";
/**
* Subscribe to an RPC event. Cleans up automatically on unmount.
*/
export function useRpcEvent<K extends keyof RpcEventSchema>(
event: K & string,
callback: (payload: RpcEventSchema[K]) => void,
) {
useEffect(() => {
return listen(event, callback);
}, [event, callback]);
}