PubSub

Even though this API does have any direct UI impact, it is actually the foundation of most Plugins.

publish()

Publish an event to any connected Subscriber via websockets.
Can be used to communicate to other people in the Room for use cases such as :
chat, dynamic content, video games, breakout rooms, polls, etc.

Subscribers are not shared between rooms.

usage :

PubSub.publish('say-hello', { data: { custom: 'payload' }})
ParamType Description
eventNamestringThe name of the event you want to publish.
data{ data: {} }Custom payload to send to the subscribers

subscribe()

Subscribe to a Published event.
Can be used to trigger any action whenever an event is Published in use cases such as :
chat, dynamic content, video games, breakout rooms, polls, etc.

usage :

PubSub.subscribe('say-hello', (message) => {})
ParamType Description
eventNamestringThe name of the event you want to subscribe to.
onEventReceivedFunction(payload)Callback called whenever a published event matches the eventName

What’s Next