feat(broadcast): migrate recipe apps to Subscribe(SelfTopic())+Publish#24
Merged
Conversation
Phase 5 of the broadcast-action-redesign proposal removes ctx.BroadcastAction
from livetemplate in v0.10.0. This PR migrates every recipe app (Go) and the
docs-site embed wiring to the new opt-in peer-fanout pattern:
- Mount: ctx.Subscribe(ctx.SelfTopic())
- Actions: ctx.Publish(ctx.SelfTopic(), "ActionName", data)
Bumps the livetemplate pin v0.9.0 → v0.9.2 in both go.mod and e2e/go.mod
(Subscribe / Publish / SelfTopic shipped via Phase 1).
Migrated 4 recipe controllers (11 BroadcastAction call sites total):
- content/recipes/counter/_app/counter.go (Increment / Decrement; new Mount)
- content/recipes/patterns/_app/handlers_realtime.go (MultiUserSync / Broadcasting / Presence — 4 sites)
- content/recipes/shared-notepad/_app/controller.go (Refresh)
- content/recipes/todos/_app/controller.go (RefreshTodos × 4)
Also reworded comment-level references in:
- cmd/site/main.go (shared-notepad embed wiring comment)
- content/recipes/shared-notepad/_app/handler.go (package doc + NewDemoBasicAuth + Handler godoc)
- content/recipes/patterns/_app/data.go (pattern catalog descriptions)
- content/recipes/patterns/_app/handlers_lists.go (SortableController godoc)
- e2e/shared-notepad/notepad_test.go (package doc test list)
- e2e/patterns/patterns_test.go (multi-tab test prose)
Substring grep across the repo for "BroadcastAction" in *.go returns zero
matches.
**Out of scope (follow-up PR):** the recipe markdown files
(content/recipes/{counter,broadcasting,sync-and-broadcast,shared-notepad/index,
counter/index,architecture-flow,progressive-enhancement/index,todos/index,
broadcasting}.md and content/index.md) still teach BroadcastAction nomenclature.
These are conceptual recipe content that needs deliberate rewriting against
the new Subscribe / Publish primitives, not a mechanical search-replace. The
content/{reference,guides}/ pages are upstream-synced from livetemplate
(see `feedback_sync_pr_edits` memory) — those will follow the livetemplate
v0.10.0 sync wave automatically.
Lands BEFORE livetemplate v0.10.0 — the migrated code uses Subscribe / Publish /
SelfTopic which already ship in v0.9.2, so this PR builds and tests cleanly
against the current published library.
Refs livetemplate#415 (broadcast-action-redesign proposal)
Refs livetemplate#429 (Phase 5 livetemplate-side PR)
Anticipating the same partial-mutation concern the claude-review raised on the examples#102 companion PR: the propagation of Publish errors as `return state, err` is intentional under the new Subscribe/Publish primitive. The only errors Publish can actually return are programmer errors (empty SelfTopic from a misconfigured Authenticator, or MaxPublishesPerAction cap exceeded). Surfacing these loudly is a feature — the alternative (log-and-swallow) hides real configuration bugs that would otherwise silently break multi-tab sync. Added a comment at content/recipes/shared-notepad/_app/controller.go's Save site explaining the rationale; the same propagation pattern is intentional at every other Publish site in the recipes. No behavior change; comment-only. Refs livetemplate#415 (broadcast-action-redesign proposal) Refs livetemplate#429 (Phase 5 livetemplate-side PR)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 5 of the broadcast-action-redesign proposal removes
ctx.BroadcastActionfrom livetemplate in v0.10.0. This PR migrates every recipe app's Go code and the docs-site embed wiring to the new opt-in peer-fanout pattern:ctx.Subscribe(ctx.SelfTopic())ctx.Publish(ctx.SelfTopic(), "ActionName", data)Bumps livetemplate pin v0.9.0 → v0.9.2 in both
go.modande2e/go.mod(Subscribe / Publish / SelfTopic already ship in v0.9.2 via Phase 1).Migrated recipes
counter/_app/counter.goIncrement/Decrement; newMountmethod addedpatterns/_app/handlers_realtime.goMultiUserSync.RefreshCounter,Broadcasting.NewMessage,Presence.PresenceChanged× 2shared-notepad/_app/controller.goRefreshtodos/_app/controller.goRefreshTodos× 4Comment-level rewording (no behavior change)
cmd/site/main.go— shared-notepad embed-wiring commentcontent/recipes/shared-notepad/_app/handler.go— package doc +NewDemoBasicAuth+Handlergodoccontent/recipes/patterns/_app/data.go— pattern-catalog descriptionscontent/recipes/patterns/_app/handlers_lists.go—SortableControllergodoce2e/shared-notepad/notepad_test.go— package-doc test liste2e/patterns/patterns_test.go— multi-tab test proseVerification
go build ./...— clean (both root +e2e/modules)go vet ./...— clean*.goforBroadcastActionreturns zero matchesOut of scope — follow-up PR
The recipe markdown files still teach BroadcastAction nomenclature:
content/index.mdcontent/recipes/architecture-flow.mdcontent/recipes/broadcasting.mdcontent/recipes/sync-and-broadcast.mdcontent/recipes/counter/index.mdcontent/recipes/shared-notepad/index.mdcontent/recipes/todos/index.mdcontent/recipes/progressive-enhancement/index.mdThese are conceptual recipe content that needs deliberate rewriting against the new Subscribe / Publish primitives — not a mechanical search-replace. Will follow as a separate
docs: migrate recipe pages to Subscribe/Publish nomenclaturePR.The
content/{reference,guides,client,contributing}/pages are upstream-synced from livetemplate — those will pick up the new API via the livetemplate v0.10.0 sync wave automatically (no edits in this repo).Ordering
This PR is intentionally landed before livetemplate v0.10.0:
Test Docs Todos / Shared Notepad / Patterns against Core Changesbecause the currentdocs/mainbuilds against the open Phase-5 livetemplate worktree, which has BroadcastAction removed)Refs livetemplate#415 (broadcast-action-redesign proposal)
Refs livetemplate#429 (Phase 5 livetemplate-side PR)
🤖 Generated with Claude Code