Skip to content

SwitchOptions

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

How switchTo opens and promotes the new subscription.

drainMs?: number;

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

How long the old subscription stays open after the cutover, in milliseconds, from 0 to 2147483647, the longest a timer holds; default 0, which cancels it at once. Groups arrive out of order across streams, most of all through another relay, so at the cutover an older group of the old track can still be in flight, or the rest of one it began. While it drains, its objects, subgroup ends and resets from groups no later than the largest it had delivered still reach the handlers, with the old track’s name, after onSwitched; its later groups and everything else are discarded.


parameters?: MessageParameters;

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

The new subscription’s parameters (location filter, priority, delivery timeout). Not inherited from the subscription being replaced: omitted means none.


signal?: AbortSignal;

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

Abandons this switch while it is pending: the new subscription is cancelled, the active one stays.


until?: "first-object" | ((object) => boolean);

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

When to cut over. The new subscription’s objects before the cutover are discarded, except those of groups later than the one that cuts over (arrived early, out of order), which follow it. 'first-object' (the default) promotes on its first object. A synchronous predicate promotes on the first object it accepts: compare the object’s own timeline (a timestamp property, say) with what the active subscription has delivered, and accept once the new track has caught up, so the cutover repeats media rather than skipping it. Group IDs are no such timeline: each track numbers its own groups, and the SDK’s publisher counts them from the track’s first sent group. Against the Mux relay a subscription without a location filter starts at the beginning of the latest group, so its first object begins a group; a subscriber on another relay can lose that first object (issue #243), which a timeline predicate absorbs.