VariantRegistry
Defined in: variant.ts:115
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VariantRegistry():
VariantRegistry
Returns
Section titled “Returns”VariantRegistry
Accessors
Section titled “Accessors”viewId
Section titled “viewId”Get Signature
Section titled “Get Signature”get viewId():
string|null
Defined in: variant.ts:140
The explicit page view the registry is scoped to, or null for the
implicit view (the one reset() starts).
Returns
Section titled “Returns”string | null
Methods
Section titled “Methods”enterView()
Section titled “enterView()”enterView(
viewId):boolean
Defined in: variant.ts:152
Scope the registry to page view viewId. A different id than the
current one starts a new page view: pins, reservations and slot
memories of the old view are dropped (as reset() does) before
anything is pinned for the new one. The same id again changes nothing,
so calling it on every render is safe. Returns true when it started a
new view.
Parameters
Section titled “Parameters”viewId
Section titled “viewId”string
Returns
Section titled “Returns”boolean
fallbackShown()
Section titled “fallbackShown()”fallbackShown(
key):boolean
Defined in: variant.ts:191
Has this slot’s fallback already been shown in this page view?
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
get(
key):string|undefined
Defined in: variant.ts:200
The variant to request for this pin key — the campaign id, or the surface id for surface-only islands — if one is already pinned. Undefined means “let the server choose” — which it should, exactly once.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | undefined
markFallbackShown()
Section titled “markFallbackShown()”markFallbackShown(
key):void
Defined in: variant.ts:186
Record that a slot’s fallback has been shown in this page view (the hold
ran out, or a server reservation revealed it). It is final for the rest
of the page view: a later mount of the same slot — a re-render, a
suspended boundary resolving — shows it again instead of holding, and
no later stream replaces it. key is the renderer’s slot identity.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
onNewView()
Section titled “onNewView()”onNewView(
listener): () =>void
Defined in: variant.ts:129
Run listener whenever a page view ends and a new one begins (a client
navigation, enterView with a different view, or reset after use).
Not for the page’s first view: state a server render left for it stays.
Returns the unsubscribe.
Parameters
Section titled “Parameters”listener
Section titled “listener”() => void
Returns
Section titled “Returns”() => void
pin(
key,variantId):string
Defined in: variant.ts:213
Record a resolved variant. First writer wins.
Later calls are ignored rather than overwriting, because a second resolution arriving at all means one island raced ahead of the pin — and in that case the right repair is to keep the value already reported on the impression, not to adopt the newer one and disagree with our own analytics.
Parameters
Section titled “Parameters”string
variantId
Section titled “variantId”string
Returns
Section titled “Returns”string
reserve()
Section titled “reserve()”reserve(
key,timeoutMs?):VariantReservation
Defined in: variant.ts:230
Claim, or wait for, this page view’s variant for a pin key (campaign id, or surface id for surface-only islands).
The first caller (per key, per page view) gets a LEADER reservation
and must eventually call resolve or abort on it. Everyone else gets a
FOLLOWER whose promise resolves with the leader’s variant, capped at
timeoutMs. A key that is already pinned returns a follower whose
promise is already resolved — awaiting it costs one microtask.
Parameters
Section titled “Parameters”string
timeoutMs?
Section titled “timeoutMs?”number = RESERVATION_TIMEOUT_MS
Returns
Section titled “Returns”reset()
Section titled “reset()”reset():
void
Defined in: variant.ts:281
New page view. Call on client-side navigation, or scope the registry to
explicit views with enterView (the provider does this for you when it
is given a serverContext or a viewKey).
Returns
Section titled “Returns”void
slot()
Section titled “slot()”slot(
key):SlotMemory
Defined in: variant.ts:163
The memory of one copy slot in this page view, created empty on first
use. key is the renderer’s slot identity. Cleared with the view.
Parameters
Section titled “Parameters”string