0.6.0 • Published 2 years ago

rohrpost v0.6.0

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

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)
	})
})
0.6.0

2 years ago

0.5.3

2 years ago

0.5.2

3 years ago

0.5.1

4 years ago

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago