# Subscriber

`class` in `http` · v0.12.0

<https://seedcord.org/docs/packages/http/0.12.0/classes/subscriber>

Base class for an HTTP subscriber, binding `this.core` to the HTTP [`Core`](/docs/packages/http/0.12.0/interfaces/core).

```ts
abstract class Subscriber<
    KeyOfSubscribers extends SubscriptionKey
> extends Subscriber<KeyOfSubscribers, Core>
```

## Constructors

### constructor

```ts
Subscriber(payload: AllSubscriptions[Keys], core: TCore, key: Keys)
```

Constructs a new instance of the `Subscriber` class

## Properties

### core

```ts
protected readonly core: TCore
```

### data

```ts
protected data: SingleKeyData<Keys>
```

The published payload. It's `never` on a subscriber for several keys, where `this.match` reads it.

### key

```ts
protected readonly key: Keys
```

### logger

```ts
protected readonly logger: Logger
```

## Methods

### execute

```ts
abstract execute(): Promise<void>
```

Executes the subscriber handler logic.

### match

```ts
protected async match<Ret, Cases>(
    cases: OnlyCases<Cases, SubscriberMatchCases<Keys, Ret>>
): Promise<MatchResult<Ret, Cases>>
```

Run the case for the published key. Use this only when the subscriber is registered for several
keys. On a single-key subscriber, read `this.data` directly.

Provide one case per registered key. Each case receives that key's own payload. A missing key or an unknown
key is a compile error.
