Skip to content

feat: add withDocumentTitle reusable#21

Open
Guria wants to merge 1 commit into
mainfrom
feat/with-document-title
Open

feat: add withDocumentTitle reusable#21
Guria wants to merge 1 commit into
mainfrom
feat/with-document-title

Conversation

@Guria

@Guria Guria commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Adds withDocumentTitle — an atom extension that mirrors a string atom's value into document.title.

  • Applicable to any AtomLike<string>, primarily a computed title.
  • Connect-gated via withConnectHook: sets the title on first subscriber, tracks changes via addChangeHook while connected, stops on disconnect. When nothing subscribes, document.title is left untouched.
  • SSR-safe: no-ops when document is undefined.
  • Extracted from a production app (guria/modern-stack src/shared/model/documentTitle.ts) — only the generic connect-hook tail; the app-specific breadcrumb/i18n computed was left behind.

Browser test covers immediate-set, update-while-connected, and no-touch-after-unsubscribe; node test covers SSR safety.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 13, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Atom extension that mirrors a string atom's value into document.title while
connected. Sets the title on the first subscriber, tracks changes via
addChangeHook, and stops on disconnect. No-ops under SSR (document undefined).
Works on any AtomLike<string>, primarily computed titles.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Guria
Guria force-pushed the feat/with-document-title branch from 33c0cb5 to d9df3b0 Compare July 13, 2026 23:48
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