VariantRegistry
Defined in: variant.ts:87
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VariantRegistry():
VariantRegistry
Returns
Section titled “Returns”VariantRegistry
Methods
Section titled “Methods”get(
key):string|undefined
Defined in: variant.ts:96
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
pin(
key,variantId):string
Defined in: variant.ts:109
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:126
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:173
New page view. Call on client-side navigation.
Returns
Section titled “Returns”void