0.1.4 • Published 2 years ago

@amgsus/hub-client v0.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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