on()
on(event: string, callback: function)
Subscribes to an event using a callback function.
Event payload signature
{
"type": "eventNameHere",
"data": {
.....................
}
}
Sample subscription code
sambaFrame.on('userJoined', (event) => {
const data = event.data;
if (data.type === 'local') {
console.log('You have joined the room');
} else {
console.log(data.user.name, 'has joined the room');
}
});
Sample subscription code with multiple callbacks
sambaFrame.on('userJoined', (event) => {
console.log('First callback called');
});
//....................................
sambaFrame.on('userJoined', (event) => {
console.log('Second callback called');
});
Last updated