Socket
Socket
Sign inDemoInstall

@mini-rpc/client

Package Overview
Dependencies
12
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mini-rpc/client

simple but effective RPC framework. Both server and client.


Version published
Weekly downloads
5
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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>()
	}
}

Keywords

FAQs

Last updated on 24 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc