@amgsus/hub-client

0.1.4 • Public • Published

Hub Client Library

Provides flexible client interface for building microservices in the Hub's ecosystem.

Basic Example

Client A

import { HubClient } from "@amgsus/hub-client";

HubClient.connectOnce().then(async (client) => {
    // Connected.
    let a = await client.retrieve("Rectangle.Width");
    let b = await client.retrieve("Rectangle.Height");
    let calculatedValue = Number(a) * Number(b);
    await client.store("Rectangle.Square", calculatedValue.toFixed(2));
    await client.disconnect();
});

Client B

import { HubClient } from "@amgsus/hub-client";

HubClient.connectOnce().then((client) => {
    client.subscribe("Rectangle.Square", (notification) => {
        console.log(`Rectangle has square ${notification.value} units`);
    });
});

Requirements

  • Node.js >= v14.15.0 LTS
  • Hub (server-side) >= v0.1.0

For older Node.js builds (<= v14.0), a key --experimental-modules is required. However, the package was not tested with older versions of Node.js.

Dependencies

No dependencies are required.

License

MIT

Package Sidebar

Install

npm i @amgsus/hub-client

Weekly Downloads

0

Version

0.1.4

License

MIT

Unpacked Size

75 kB

Total Files

14

Last publish

Collaborators

  • amgsus