# Bus

`class` in `seedcord` · v0.14.0

<https://docs.seedcord.org/packages/seedcord/0.14.0/classes/bus>

Manages application subscribers and event handling

Provides a centralized system for registering and executing custom subscribers throughout the application lifecycle. Bus subscribers are loaded from configured directories and can be triggered programmatically or by framework events. Accessed via `core.bus`, not constructed directly.

```ts
class Bus extends Plugin<SubscriptionTuples>
```

## Constructors

### constructor

```ts
Bus(core: Core)
```

Constructs a new instance of the `Bus` class

## Properties

### core

```ts
protected core: Core
```

### logger

```ts
public readonly logger: Logger
```

### name

```ts
public readonly name
```

### pluggable

```ts
protected pluggable: Core
```

## Methods

### init

```ts
abstract async init(): Promise<void>
```

Initialize the plugin - implement setup logic here Override this method in your plugin classes

### onHmr

```ts
async onHmr(_event: HmrUpdateEvent): Promise<void>
```

Reloads plugin state on an HMR update.

### publish

```ts
public publish<KeyOfSubscribers>(
    event: KeyOfSubscribers,
    data: AllSubscriptions[KeyOfSubscribers]
): boolean
```

Publishes an event to its subscribers and native listeners.

Fire-and-forget, so subscriber handlers run asynchronously and this returns before they complete, and callers must not assume side effects have landed. Errors thrown by a subscriber are caught and logged, never surfaced here. A `'once'` subscriber is marked as executed when it starts (even if it throws), so it never runs twice.

### registerCriticalFiles

```ts
protected registerCriticalFiles(
    patterns: string[]
): void
```

Registers critical file patterns that should trigger a full restart when changed in Dev HMR.
