6.0.14 • Published 2 years ago

katamari-client v6.0.14

Weekly downloads
3
License
MIT
Repository
-
Last release
2 years ago

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()
}
6.0.14

2 years ago

6.0.12

2 years ago

6.0.11

3 years ago

6.0.10

4 years ago

6.0.8

4 years ago

6.0.7

4 years ago

6.0.6

5 years ago