Skip to content

🍕 Document value-shaped state pattern beyond sticky events - #261

Merged
jjpaulino merged 1 commit into
masterfrom
jordan/client-state-docs
Sep 15, 2026
Merged

jjpaulino merged 1 commit into
masterfrom
jordan/client-state-docs

Conversation

@jjpaulino

Copy link
Copy Markdown
Member

TL;DR — for reviewers short on time

  • Outcome and scope: Docs-only. Adds a new CLAY-VITE.md section generalizing a real production bug (a vendor consent-management callback answered by a stale no-op because Vite's deferred bootstrap runs it too late) into the underlying pattern: Vite's async bootstrap removed the total execution order Browserify gave every site for free, and stickyEvents only covers one narrow instance of the resulting race class. Documents a value-shaped store pattern (get/set/subscribe, subscribe fires immediately with the current value) as the fix for any cross-cutting client fact — explicitly framed as a pattern for site code, not a claycli API. No code changes.
  • Risk: None. Pure documentation addition; no .js file touched.
  • Validation: N/A (docs only) — reviewed for technical accuracy against the actual mechanics of stickyEvents (generate-bootstrap.js) and the bootstrap timing it describes; matches the doc's existing voice and heading structure (placed as a sibling deep-dive alongside "Sticky events" and "Watch mode" under Section 8).
  • If you only review one thing: CLAY-VITE.md L1018–L1032 — "Why stickyEvents doesn't reach this": the section's most important claim, and the one most likely to be second-guessed. It doesn't overstate what stickyEvents does — it precisely scopes what it can't reach (a third-party vendor callback slot) and why (nothing in claycli's bootstrap is anywhere near that call path).
  • Changes, in logical review order:
    1. CLAY-VITE.md L965–L989 — the general race shape (one-shot signal fired before the interested code can subscribe), named beyond just the worked example: vendor callbacks, one-shot MutationObservers, uncovered custom events.
    2. CLAY-VITE.md L991–L1016 — the worked example (OptanonWrapper answered by the page's own inline no-op) grounding the general shape in a real incident.
    3. CLAY-VITE.md L1034–L1070 — the value-shaped store pattern (illustrative pseudocode, explicitly labeled as site-code, not claycli API).
    4. CLAY-VITE.md L1072–L1107 — the companion boundary-adapter pattern, and why it must be a synchronous inline script.
    5. CLAY-VITE.md L1109–L1132 — explicitly rules out "run component imports eagerly" as a substitute fix, and frames stickyEvents as a bridge rather than deprecating it outright.

Feature Info

Description

Generalizes a fixed incident (a vendor consent callback race) into documented guidance for the whole class of bug, so the next vendor integration or cross-component signal has a pattern to reach for instead of reinventing a per-file catch-up fix. Companion to the code-level fixes landing in the other three PRs from this pass (#258, #259, #260).

🤖 Generated with Claude Code

Adds a new section to CLAY-VITE.md, "Beyond sticky events: value-shaped
state for cross-cutting client facts", immediately after the existing
Sticky Events section.

It generalizes the ESM dynamic-import race beyond stickyEvents' narrow
event-replay coverage: a one-shot signal (event, or vendor-assigned
callback slot) fired before interested code has subscribed is lost for
that pageview. Uses the OneTrust/OptanonWrapper production incident as
a worked example, explains precisely why stickyEvents can't help with
a third-party vendor callback slot (and is edge-shaped even where it
does apply), and documents the recommended value-shaped store pattern
(get/set/subscribe, with an inline synchronous script owning the
vendor callback slot) as guidance for consuming-site code — not a
claycli API. Explicitly rules out eager/static component imports as a
substitute fix, notes claycli's own role is this guidance plus an
existing build-time window.<Identifier> diagnostic, and frames
stickyEvents as a bridge that migrated events can eventually drop.

Also adds one QA checklist item confirming no component's client.js
depends on winning a race against a third-party vendor callback or
another component's one-shot signal.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 87.018%. remained the same — jordan/client-state-docs into master

@jjpaulino jjpaulino self-assigned this Sep 15, 2026
@jjpaulino
jjpaulino merged commit e6aee74 into master Sep 15, 2026
6 checks passed
@jjpaulino
jjpaulino deleted the jordan/client-state-docs branch September 15, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants