> This page is for Browser SDK, version v3.
> For other versions, use one of these documentation indexes:
> - v4 (default): https://signalwire.com/docs/browser-sdk/v4/llms.txt
> - v3: https://signalwire.com/docs/browser-sdk/v3/llms.txt
> - v2: https://signalwire.com/docs/browser-sdk/v2/llms.txt

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# on

> on method for the RoomSession class.

### on

* **on**(`event`, `fn`)

Attaches an event handler to the specified event.

#### Parameters

| Name    | Type     | Description                                                                                               |
| :------ | :------- | :-------------------------------------------------------------------------------------------------------- |
| `event` | `string` | Name of the event. See the list of [events](/docs/browser-sdk/v3/js/reference/video/room-session/events). |
| `fn`    | Function | An event handler.                                                                                         |

#### Example

In the below example, we are listening for the `call.state` event and logging the current call state to the console.
This means this will be triggered every time the call state changes.

```js
call.on("call.state", (call) => {
    console.log("call state changed:", call.state);
});
```