rohrpost

0.6.0 • Public • Published

rohrpost-js Build Status Coverage Status npm

Client

Constructor

new RohrpostClient(URL, {pingInterval: 5000, token: $YOUR_JWT})

Subscribe to a group

subscribe(groupObject)

groupObject is defined by the application, for example {type: 'collection', id: 5}

returns a Promise, resolves with groupName string, use this to listen to events

Unsubscribe from a group

unsubscribe(groupObject)

Listen to events on a group

on(groupName, function(err, data))

Example

const url = 'wss://api-stage.ax-semantics.com/ws/rohrpost/'
const token = 'ey-jwt'
const colletionId = 23
const client = new RohrpostClient(url, {token})

client.on('open', () => {
	client.subscribe({type:'collection', id: collectionId}).then((data) => {
		console.log(`subscribed to ${data.group}`)
		client.on(data.group, (err, data) => {
			console.log(`got ${data.type} on ${data.group} : ${JSON.stringify(data.object)}`)
		})
	}).catch((err) => {
		console.error(err)
	})
})

Readme

Keywords

none

Package Sidebar

Install

npm i rohrpost

Weekly Downloads

8

Version

0.6.0

License

MIT

Unpacked Size

96.6 kB

Total Files

14

Last publish

Collaborators

  • rash
  • ax-semantics