SwitchableSubscription
Defined in: relay-sdks/ts/src/switchable.ts:107
The handle RelaySubscriber.subscribeSwitchable() returns.
Properties
Section titled “Properties”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.
pending
Section titled “pending”readonly pending: string | undefined;Defined in: relay-sdks/ts/src/switchable.ts:111
The pending subscription’s track name, while a switch is pending.
subscribed
Section titled “subscribed”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.
Methods
Section titled “Methods”cancel()
Section titled “cancel()”cancel(reason?): void;Defined in: relay-sdks/ts/src/switchable.ts:134
Cancel the active subscription and any pending one. Idempotent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reason? |
unknown |
Returns
Section titled “Returns”void
switchTo()
Section titled “switchTo()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
track |
string |
options? |
SwitchOptions |
Returns
Section titled “Returns”Promise<SwitchedInfo>