actions/rpc_client.ts view source
<TApi extends object>(options: CreateRpcClientOptions<TApi>): TApi import {create_rpc_client} from '@fuzdev/fuz_app/actions/rpc_client.js'; Creates a Proxy-based API from action specs.
Method calls are dynamically dispatched based on the action spec's kind:
request_response→ send request, await response, return Resultremote_notification→ send notification, return Resultlocal_call→ execute locally (sync or async), return Result or throw
Generic TApi is the consumer's typed Proxy interface (typically a
codegen-derived ActionsApi). Required — no default, so forgetting it
is a type error rather than a silent slide into any. The `as unknown
as TApi` coercion lives inside this function so call sites get a typed
return without a cast at the seam. TApi is a type-layer promise about
what the Proxy responds to; the runtime walks specs (kept in sync by
the consumer, codegen recommended).
const api_result = create_rpc_client<MyActionsApi>({peer, environment});options
CreateRpcClientOptions<TApi>returns
TApi a Proxy typed as TApi that responds to any method name found in the environment's specs
generics
create_rpc_client<TApi extends object>TApi
object