> For the complete documentation index, see [llms.txt](https://pahutyakv.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pahutyakv.gitbook.io/docs/evently/evently-bus.md).

# Evently Bus

Evently supports two types of event buses: the **Global Bus** and **Scoped Buses**.\
Both provide the same functionality, but differ in **lifetime and usage scope**.

***

### <mark style="color:$success;">**Global Bus**</mark>

The Global Bus is the default static event bus used by Evently.

It is accessed through the static API:

```csharp
Evently.Subscribe<T>()
Evently.Publish<T>()
```

The global bus is intended for **project-wide communication** where multiple systems may need to react to the same events.

Typical examples include events such as `GameStarted / PlayerDied / LevelLoaded`

Listeners registered on the global bus remain active for the lifetime of the application unless they are:

* explicitly unsubscribed
* automatically disposed via `.BindTo(MonoBehaviour)`

Because the global bus persists across the entire project, it is best suited for:

* core gameplay systems
* global managers
* cross-scene events
* systems that need to communicate across large parts of the codebase

***

### <mark style="color:$success;">**Scoped Bus**</mark>

A Scoped Bus is an independent instance of `EventlyBus`.

It can be created using:

```csharp
EventlyBus bus = Evently.CreateScope();
```

Unlike the global bus, a scoped bus maintains **its own isolated set of event listeners**.\
Events published on a scoped bus are only received by listeners registered on that same bus.

This makes scoped buses useful for **modular or temporary systems** where event communication should remain local.

Common use cases include:

* UI panels
* mini-games
* temporary gameplay modules
* isolated subsystems
* testing environments

The scoped bus exists as long as a reference to the `EventlyBus` instance is maintained.\
This prevents scoped systems from accidentally leaking subscriptions into the global event space.
