0.3.1 • Published 4 years ago

@vmisztvl/tiny-rpc v0.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

tiny-rpc

A node package that allows rpc over websockets and pushing messages from server to client.

  • Focused on simplicity.
  • Promise api.
  • Written in typescript.

Package repo

Full example

Server

import { RpcServer } from '@vmisztvl/tiny-rpc';

const rpc = new RpcServer(server, '/rpc');

rpc.registerHandler('getTime', () => Date.now());

rpc.onNewClient = (client) => client.post('messages', 'Hello client!');

Client

import { RpcClient } from '@vmisztvl/tiny-rpc';

const rpc = new RpcClient('/rpc');

rpc.subscribe('messages', addMessage);

button.onclick = async () => {
  const data = await rpc.call('getTime');
  console.log(data);
};

Please do submit feature requests / bugs / questions / suggestions.

0.3.1

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.2

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago