katamari-client
TypeScript icon, indicating that this package has built-in type declarations

6.0.14 • Public • Published

katamari-client

Test

npm

js client for katamari though the service should be usable with the standard websocket and http/fetch request method, this client provides encode/decode methods and a reconnecting websocket abstraction.

Messages will arrive either as a snapshot or a patch the subscription keeps a cache of the latest state.

how to

install

npm i katamari-client

object

import Katamari from 'katamari-client'

const client = Katamari('localhost:8800/box')
let msgs = []
client.onopen = async () => {
  await client.publish('box', { name: 'something 🧰' }) // create
  await client.publish('box', { name: 'still something 💾' }) // update
  await client.unpublish('box') // delete
}
client.onmessage = async (msg) => { // read
  msgs.push(msg)
  if (msgs.length === 4) {
    client.close()
    console.log(msgs)
  }
}
client.onerror = (err) => {
  client.close()
}

list

import Katamari from 'katamari-client'

const client = Katamari('localhost:8800/box/*')
let msgs = []
client.onopen = async () => {
  const id = await client.publish('box/*', { name: 'something 🧰' }) // create
  await client.publish('box/' + id, { name: 'still something 💾' }) // update
  await client.publish('box/custom', { name: 'custom something 🧰' }) // create
  await client.unpublish('box/*') // delete list
}
client.onmessage = async (msg) => { // read
  msgs.push(msg)
  if (msgs.length === 5) {
    client.close()
    console.log(msgs)
  }
}
client.onerror = (err) => {
  client.close()
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
6.0.148latest

Version History

VersionDownloads (Last 7 Days)Published
6.0.148
6.0.120
6.0.110
6.0.100
6.0.80
6.0.70
6.0.60

Package Sidebar

Install

npm i katamari-client

Weekly Downloads

8

Version

6.0.14

License

MIT

Unpacked Size

30.9 kB

Total Files

13

Last publish

Collaborators

  • benitogf