@amgsus/hub-client
v0.1.4
Published
Client library for Hub server (Node.js)
Downloads
4
Maintainers
Readme
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