import type { RpcClient } from "@neoinkjs/rpc"; /** * Subscribes to notifications named `method` on `client`, narrowing each * notification's first parameter with `isValue` before handing it to * `handler`; anything with a different method name, or whose first param * fails the guard, is silently ignored. Both `subscribeInput` (`input.ts`) * and `subscribeResize` (`resize.ts`) are this exact shape — one method * name, one narrowed scalar param — so it lives here once rather than being * copy-pasted per notification kind. */ export function subscribeNotification( client: RpcClient, method: string, isValue: (value: unknown) => value is T, handler: (value: T) => void, ): () => void { return client.onNotification((receivedMethod, params) => { if (receivedMethod !== method) return; const value = params[0]; if (isValue(value)) handler(value); }); }