> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# 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);
});
```