Skip to content

SwitchableSubscription

Defined in: relay-sdks/ts/src/switchable.ts:107

The handle RelaySubscriber.subscribeSwitchable() returns.

readonly ended: Promise<SubscriptionEnd>;

Defined in: relay-sdks/ts/src/switchable.ts:122

Settles once, with the active subscription’s ending, when it ends other than by a cutover, or when cancel() runs. Any pending switch is cancelled with it. Never rejects.


readonly pending: string | undefined;

Defined in: relay-sdks/ts/src/switchable.ts:111

The pending subscription’s track name, while a switch is pending.


readonly subscribed: Promise<SubscribeOk>;

Defined in: relay-sdks/ts/src/switchable.ts:117

Resolves with the acceptance info of the first subscription to be active and accepted: the first one, or the one a switch made before the first one was answered. Rejects as RelaySubscription.subscribed does if the switchable ends before that.


readonly track: string;

Defined in: relay-sdks/ts/src/switchable.ts:109

The active subscription’s track name.

cancel(reason?): void;

Defined in: relay-sdks/ts/src/switchable.ts:134

Cancel the active subscription and any pending one. Idempotent.

Parameter Type
reason? unknown

void


switchTo(track, options?): Promise<SwitchedInfo>;

Defined in: relay-sdks/ts/src/switchable.ts:132

Subscribe to track in the same namespace, keep delivering the active subscription until the new one’s object passes until, then cancel the old one. The track may be the active one, to change parameters. A newer switchTo cancels a pending one, which rejects with CLOSED. Rejects as RelaySubscription.subscribed does if the new subscription ends before its cutover, with the signal’s reason when the signal aborts it, or with the thrown error when until throws; the active subscription carries on. Throws at once for an invalid track or options, a closed connection, or an ended switchable.

Parameter Type
track string
options? SwitchOptions

Promise<SwitchedInfo>