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

0.2.0 • Public • Published

lRPC client

Build Status License Library minified size Library minified + gzipped size

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install @lrpc/client --save

# For Yarn, use the command below.
yarn add @lrpc/client

Installation from CDN

This module has an UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/@lrpc/client"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/@lrpc/client"></script>

<script>
  // UMD module is exposed through the "lrpc" global variable.
  console.log(lrpc);
</script>

Usage

This package exports an async function createClient, which accepts the URL of your API and provides you with a javascript Proxy object that will convert your function calls into RPCs.

async main () {
  const client = await createClient('http://localhost:3000') // This calls a handshake function on the server

  const { greeting } = client.greet({ name: 'John' }) // 'Hello, John'
}

main()
  .catch(console.error)

License

Released under MIT License.

Package Sidebar

Install

npm i @lrpc/client

Weekly Downloads

0

Version

0.2.0

License

GPL-3.0

Unpacked Size

46.5 kB

Total Files

23

Last publish

Collaborators

  • rjmunhoz