# Events

With events you can subscribe to various things which are happening inside the room.

For example you may want to hide the iframe when user leaves the meeting -> then you will subscribe to the [userLeft](https://docs.digitalsamba.com/reference/sdk/events/userleft) event. For the full list of events please have a look at the navigation bar on the left.

You will subscribe to an event with the [on()](https://docs.digitalsamba.com/reference/sdk/methods/on) method and unsubscribe with the [off()](https://docs.digitalsamba.com/reference/sdk/methods/off) method.\
There is also the [once()](https://docs.digitalsamba.com/reference/sdk/methods/once) method for subscription, but it's only a one-time subscription and is used rarely in general. The events architecture is built upon the commonly used [EventEmitter](https://nodejs.org/api/events.html#class-eventemitter) interface.

#### Templates for subscription/unsubscription:

```javascript
sambaFrame.on('eventNameHere', (event) => {
   //Execute your own custom logic here
});

sambaFrame.once('eventNameHere', (event) => {
   //This will execute ONLY ONCE, even if the event happens a hundred times
});

const myCallback = (event) => {
   //Execute your own custom logic here
});
sambaFrame.on('eventNameHere', myCallback);
//........................................

//Unsubscribe if you want at some point later
sambaFrame.off('eventNameHere', myCallback);
```

{% hint style="info" %}
There is a special event named '**\***', which can be useful for debugging purposes to see all incoming events and their data.\
\
`sambaFrame.on('*', (event) => {`&#x20;

&#x20;  `console.log(event);`

`});`
{% endhint %}
