# SupervisedSubscriber

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/supervisedsubscriber/

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:180](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L180)

A subscriber that reconnects and keeps wanted tracks subscribed. Create one with
[connectSupervisedSubscriber](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/functions/connectsupervisedsubscriber/).

## Properties

### closed

```ts
readonly closed: Promise<{
  error?: unknown;
}>;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:202](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L202)

Resolves once the supervisor stops: `close()`, the signal, or a failure it does not retry. Never rejects.

***

### status

```ts
readonly status: SupervisedStatus;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:200](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L200)

Where the supervisor stands; see [SupervisedStatus](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/supervisedstatus/).

## Methods

### catchUp()

```ts
catchUp(key): void;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:198](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L198)

Replace a want's accepted subscription at once, break-before-make, because it delivers too late to use: cancel it,
which makes the relay drop what it still holds queued for it, and subscribe again with the same options, so a
want without a location filter starts at the newest group. `onRestarted` reports `'catch-up'`. A frame reader's
`onCatchUp` is the usual caller. The new subscription opens without delay when the old one had moved past its
first group, and otherwise after the want's `retry` backoff, so a link too slow for the track cannot make it spin.
Ignored for an unknown key and while no subscription is accepted.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `string` |

#### Returns

`void`

***

### close()

```ts
close(): void;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:215](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L215)

Stop reconnecting, cancel every want and close the connection. Idempotent.

#### Returns

`void`

***

### rotate()

```ts
rotate(): void;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:213](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L213)

Replace the connection make-before-break, as happens on its own `rotateBeforeMs` before the credential expires: a
new connection opens, with a fresh token, and every want moves its subscription to it as a move would, keeping the
old one delivering until the cutover. A want whose target is unchanged cuts over on the first object the old one did
not deliver, with no callback: nothing is lost or repeated. The old connection closes once every want has moved,
after 10 seconds at most. A no-op while no connection is up.

#### Returns

`void`

***

### unwant()

```ts
unwant(key): void;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:189](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L189)

Cancel a want's subscription and forget it. Unknown keys are ignored.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `string` |

#### Returns

`void`

***

### want()

```ts
want(
   key, 
   options, 
   handlers?
): void;
```

Defined in: [relay-sdks/ts/src/supervised-subscriber.ts:187](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-subscriber.ts#L187)

Keep a subscription to a track open until `unwant(key)`. Wanting a key again with the same namespace and
`generations` updates the want in place: the handlers, `retry`, `staleAfterMs`, `until` and `drainMs` are swapped,
and another track or parameters moves the subscription make-before-break. Another namespace or `generations`
replaces the want. Arguments are checked at once.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `string` |
| `options` | [`WantOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/wantoptions/) |
| `handlers?` | [`WantHandlers`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/wanthandlers/) |

#### Returns

`void`
