onRpc
Callable
- onRpc<K>(rpcName: K, listener: (...args: Parameters<ICustomServerClientRpc[K]>) => ReturnType<ICustomServerClientRpc[K]> | Promise<ReturnType<ICustomServerClientRpc[K]>>): void
- onRpc<K>(rpcName: Exclude<K, never>, listener: (...args: any[]) => any): void
Type parameters
- K: never
Subscribes to a server -> client RPC with the specified listener.
Example
Remarks
The return value of the listener function determines the response server will receive. When returning multiple values, use an array. Returning an Error object will cause the promise on the server to throw an exception which has to be caught.