Add Pub/Sub "Live voting" example (message annotations)#3394
Open
SimonWoolf wants to merge 2 commits into
Open
Add Pub/Sub "Live voting" example (message annotations)#3394SimonWoolf wants to merge 2 commits into
SimonWoolf wants to merge 2 commits into
Conversation
Add an interactive "Live voting" example at /examples/pub-sub-live-voting demonstrating message annotations: a poll is a message, each vote is a `vote:unique.v1` annotation, and Ably aggregates votes into a summary. The live widget shows voter + presenter panes side by side (d-pad poll auto-started via a sandbox-only bootstrap that seeds a few votes). The full app — admin/voter/presenter client plus an Express server (role-scoped JWT auth, shows API, static SHOWS_FILE and Postgres stores) — ships under the example so it can be cloned and run as a real voting app. Wiring: register the example, give its two preview panes per-role start routes and Voter/Presenter labels, and add the qrcode dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add an optional `githubUrl` to example metadata so the "View on GitHub" button can target a canonical home other than the docs repo, and set it for pub-sub-live-voting to ably-demos/live-voting-with-annotations. Repoint the README's clone/source links to the same standalone repo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What
Adds an interactive Live voting example at
/examples/pub-sub-live-voting, focused on message annotations: a poll is a message, each vote is avote:unique.v1annotation, and Ably aggregates votes into a summary — no database, no client-side tallying.The live widget shows voter + presenter panes side by side. On load a sandbox-only bootstrap auto-starts the d-pad poll and seeds a few votes so the presenter (heatmap + leader badge + vote bubbles) is alive immediately; the voter pane then votes live on top.
Structure
Everything for the full app lives under
examples/pub-sub-live-voting/javascript/so the in-page Open in CodeSandbox export is complete:javascript/root (voter/presenter/admin views, branched by?role=)server/— Express: role-scoped JWT/auth, shows API, staticSHOWS_FILEand Postgres storesdata/(static poll data) anddatabase/(schema + migrations)Sandbox vs. clone: the live widget has no backend, so it falls back to a raw key (loudly commented as demo-only) and a per-role channel mode split; a real clone uses the server's token auth. The canonical runnable source lives in the standalone ably-demos/live-voting-with-annotations, which the README and the new "View on GitHub" override point to.
Shared-infra touches (kept minimal / backward-compatible)
ExamplesRenderer: per-id start routes (?role=voter/?role=presenter&demo=1) + Voter/Presenter pane labels; addqrcodedependency.examples.tsx+Exampletype: optionalgithubUrlto override the "View on GitHub" target (defaults unchanged for every other example).gatsby-config:ignorenode_modules/diston the examples source — required now that a nestedserver/can have its own installed deps under a sourced language dir.Verification
yarn lintclean (0 errors); standalone servernpm install+tscclean; clientvite buildclean. Live behaviour (two panes, voting → heatmap/bubbles) should be eyeballed on the review app — it needs the Message annotations channel rule on thevoting:*namespace of the demo app.🤖 Generated with Claude Code