@viviedu/applet-sdk
v0.7.0
Published
SDK for building Vivi Applets
Downloads
329
Keywords
Readme
Vivi Applet SDK
A small JavaScript library and example code for implementing Vivi Applets.
Installing
$ pnpm add @viviedu/applet-sdk$ yarn add @viviedu/applet-sdkInstalling via git
It can be helpful when developing to install a version that's on Github. Both pnpm and yarn support this, see the following commands. This assumes SSH authentication for Github has been setup as this is a private repository.
$ pnpm add viviedu/vivi-applet-sdk[#optional_tag_branch_or_sha]$ yarn add git+ssh://[email protected]:viviedu/vivi-applet-sdk.git[#optional_tag_branch_or_sha]Usage
Define your command types
type AppletCommand =
{ type: 'foo', content: string }
| { type: 'bar', content: number }Create the applet with your command types
const applet = new ViviApplet<AppletCommand>();Send a command
await applet.send({
type: 'foo',
content: 'hello, world!'
});Listen to and handle commands:
applet.listen((command) => console.log(command.content))