add UDN frontend module

This commit is contained in:
marlon-erler
2024-07-07 13:46:27 +02:00
parent a4633669cf
commit 9dd55f650b
8 changed files with 811 additions and 2 deletions
+29
View File
@@ -0,0 +1,29 @@
# udn-frontend
TypeScript library for [UDN](https://github.com/marlon-erler/universal-decentralized-network) apps
# Install
`npm install udn-frontend`
# Usage
```TypeScript
import UDNFrontend from "udn-frontend";
// setup
const UDN = new UDNFrontend();
UDN.onconnect = () => {
console.log("connected!");
};
UDN.ondisconnect = () => {
console.log("disconnected!");
};
UDN.onmessage = (data) => {
console.log(data);
};
// do stuff
UDN.connect("ws://192.168.0.69:1234");
UDN.subscribe("my-channel");
UDN.sendMessage("my-channel", "Hello, world!");
UDN.unsubscribe("my-channel");
```