0.2.0 • Published 3 years ago

@lrpc/client v0.2.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 years ago

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.

0.1.0

3 years ago

0.2.0

3 years ago

0.0.1

3 years ago