import { MRpc } from "@mys-x/m-rpc"; // or "jsr:@mys/m-rpc"
function add(a: number, b: number) {
return a + b;
}
// The port can be a MessagePort, a WebSocket, a Worker, or a WorkerGlobalScope
const { port1, port2 } = new MessageChannel();
const rpc1 = new MRpc(port1);
const rpc2 = new MRpc(port2);
rpc1.defineLocalFn("add", add);
await rpc2.callRemoteFn<typeof add>("add", [1, 2]); // 3
generated from mys1024/starter-deno
-
Notifications
You must be signed in to change notification settings - Fork 0
A message based rpc library.
License
mys1024/m-rpc
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A message based rpc library.
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published