0.0.3 • Published 3 years ago

@locutus/locutus-stdlib v0.0.3

Weekly downloads
-
License
MIT+APACHE-2.0
Repository
github
Last release
3 years ago

Locutus Javascript/Typescript Std Lib

Locutus Javascript/Typescript Standard Library contains utilities for developing web apps which interact with Locutus node.

The stdlib offers a series of facilities in which you will be able to communicate with the network ergonomically.

Here is a minimal example of how you could write your application to interact with the node:

import { LocutusWsApi } from "@locutus/locutus-stdlib/webSocketInterface";

const handler = {
  onPut: (_response: PutResponse) => {},
  onGet: (_response: GetResponse) => {},
  onUpdate: (_up: UpdateResponse) => {},
  onUpdateNotification: (_notif: UpdateNotification) => {},
  onErr: (err: HostError) => {},
  onOpen: () => {},
};

const API_URL = new URL(`ws://${location.host}/contract/command/`);
const locutusApi = new LocutusWsApi(API_URL, handler);

const CONTRACT = "DCBi7HNZC3QUZRiZLFZDiEduv5KHgZfgBk8WwTiheGq1";

async function loadState() {
  let getRequest = {
    key: Key.fromSpec(CONTRACT),
    fetch_contract: false,
  };
  await locutusApi.get(getRequest);
}
0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago