Nostalgic Primordial Monster

    @mini-rpc/client
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3 • Public • Published

    Mini-RPC

    simple but effective RPC framework. Both server and client.

    Usage

    Get start

    Install

    npm i @mini-rpc/client
    # or
    pnpm add @mini-rpc/client
    # or
    yarn add @mini-rpc/client

    Client

    import { RPCClient } from "@mini-rpc/client";
    
    const client = new RPCClient("ws://localhost:3000");
    client.connect();
    
    client
      .call("add", [1,2,3])
      .then((result) => {
        console.log(result); // 6
      })
      .catch((err) => {
        console.error(err);
      });

    Tips

    • the @Callable method can be asynchronous.
    class x {
    	//...
    
    	@Callable()
    	async add(a:number,b:number) {
    		// asynchronous code
    	}
    	
    	// or declare the return type Promise
    
    	@Callable()
    	promiseAdd(a:number,b:number):Promise<number> {
    		return Promise<number>()
    	}
    }

    Install

    npm i @mini-rpc/client

    DownloadsWeekly Downloads

    2

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    4.99 kB

    Total Files

    8

    Last publish

    Collaborators

    • xiaoliu-heng