# WantHandlers

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

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

The callbacks a want delivers to. Like `RelaySubscriptionHandlers`, they must be synchronous.

## Methods

### onError()?

```ts
onError?(error): void;
```

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

A failure the want does not retry, after which it stops and is removed: a REQUEST_ERROR no wait fixes
(credentials, an unsupported or malformed request), or discovery refusing the root.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `error` | `unknown` |

#### Returns

`void`

***

### onObject()?

```ts
onObject?(object): void;
```

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

One object, from whichever subscription is current.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `object` | [`MoqtObject`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/moqtobject/) |

#### Returns

`void`

***

### onPublisherDone()?

```ts
onPublisherDone?(info): void;
```

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

The relay sent PUBLISH_DONE on the current subscription; the want resubscribes after its backoff.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | [`PublishDone`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishdone/) |

#### Returns

`void`

***

### onRestarted()?

```ts
onRestarted?(info): void;
```

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

An accepted subscription ended and the want will replace it: drop decoder state that assumed continuity. Called
before any object of the replacement; the gap is never filled.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | \{ `namespace`: `string`[]; `reason`: [`RestartReason`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/restartreason/); \} |
| `info.namespace` | `string`[] |
| `info.reason` | [`RestartReason`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/restartreason/) |

#### Returns

`void`

***

### onSubgroupEnd()?

```ts
onSubgroupEnd?(info): void;
```

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

A subgroup stream ended cleanly.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | \{ `endOfGroup`: `boolean`; `groupId`: `number`; `subgroupId`: `number`; \} |
| `info.endOfGroup` | `boolean` |
| `info.groupId` | `number` |
| `info.subgroupId` | `number` |

#### Returns

`void`

***

### onSubgroupReset()?

```ts
onSubgroupReset?(info): void;
```

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

A subgroup stream was reset.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | \{ `error`: `unknown`; `groupId`: `number`; \} |
| `info.error` | `unknown` |
| `info.groupId` | `number` |

#### Returns

`void`

***

### onSubscribed()?

```ts
onSubscribed?(info, context): void;
```

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

A subscription was accepted; `namespace` is the one it was made on, the generation's when following one. A move's
replacement reports its acceptance in `onSwitched` instead.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | [`SubscribeOk`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscribeok/) |
| `context` | \{ `namespace`: `string`[]; \} |
| `context.namespace` | `string`[] |

#### Returns

`void`

***

### onSwitched()?

```ts
onSwitched?(info): void;
```

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

A move's cutover: the want now delivers from `to`, and `from` was cancelled or drains its in-flight groups. Runs
before the replacement's first object, the one that passed `until`. Decoders drop state that assumed continuity
here; no `onRestarted` or `onSubscribed` runs for a move.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | [`WantSwitchedInfo`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/wantswitchedinfo/) |

#### Returns

`void`
