# The stateManager.once() method
This documents the `stateManager.once()` method.

There are multiple parameters for this method, and a deeper dive into each of them can be found in the [Events -> Introduction page](/documentation#Events/6-events-intro) and all of the pages within the Events category.

<div class="info-box">
    <span class="material-icons">info</span>
    <div>
        <strong>In Short:</strong> The difference between on() and once() is that on() stays connected until removed or the client disconnects, while once will detach after the first event.
    </div>
</div>

## How is this different from stateManager.on()?
Generally, the format is just:
```ts
taClient.stateManager.once('eventType', () => {
    // callback function
})
```
or
```ts
async function handleEvent(params) {
    // code here
}

taClient.stateManager.once('eventType', handleEvent);
```

Essentiallly both are the same thing. The point is that when an event happens, depending on your subscription type, different types of data will be passed through to a method(callback). The reason why `once()` is different is because it automatically detaches after the first event. That means the callback method is only triggered once, and then the listener is removed.

The listener also detaches upon a disconnect from the `CoreServer`.

## Its events
The events in `once()` are the exact same as in `on()`. There is no direct implementation in ShyyTAUI, as there really is not a scenario when you want a listener to only trigger once. 

You might wonder why that is. Why is it not enough to listen to a `matchDeleted` event once? The answer is simple. Since just like `on()`, `once()` also gets triggered by other tournaments' data changes and not just the current match getting deleted. 