Client Phase 2: Push Event Example and Test Coverage #15
Closed
SeanTAllen
started this conversation in
Research
Replies: 1 comment
-
|
implemented in #16 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
Server Phase 2 added external message delivery (
handle_info,InfoReceiver,PubSub,push_event). Client Phase 1 proactively implemented push message handling — decode and dispatch viaLiveView.on(event, callback). The infrastructure is complete end-to-end but never demonstrated: the ticker example works entirely through assign changes → re-render, never callingpush_eventoron().Client Phase 2 closes this gap by enhancing the ticker to demonstrate both mechanisms and adding client-side test coverage for push event edge cases.
Change classification: Internal (example enhancement, tests, docs). VERSION is 0.0.0 — no release notes.
Design Decision: Enhance Ticker vs. New Example
Options:
(A) Enhance the ticker example to call
push_eventinhandle_infoand useon()in the HTML. Shows both re-render and push event mechanisms working together.(B) Create a separate example (e.g., "notifications") that demonstrates push events independently.
Recommendation: Option A. The ticker already demonstrates server push via PubSub. Adding
push_eventshows the full picture — server-rendered DOM updates AND client-side push event handling — in one coherent example. A separate example adds file proliferation for what's a natural extension of the ticker's existing behavior.Steps
1. Modify
examples/ticker/main.ponyAdd a
push_eventcall inhandle_infoto send the timer tick count alongside the assign update:Uses unqualified
JsonObjectmatching the existing example import convention (use "json").Demonstrates the key distinction:
Ticks: Nheading updates via morphdom#push-logelement updates viaon()handler2. Modify
examples/ticker/index.htmlAdd a push event handler and a DOM element outside the LiveView container:
#lv-root: managed by the server (morphdom re-renders)#push-log: managed by the client (on()callback)3. Add client tests for push edge cases
Add to
client/test/live-view.test.js:on()overwrites previous handler for same event — second registration replaces first4. Update
examples/README.mdUpdate the ticker entry to mention push events alongside re-renders.
5. Update
CLAUDE.mdUpdate the file layout ticker comment to reflect that it also demonstrates
push_eventand client-side push handling.6. Build and verify
Files
examples/ticker/main.ponyexamples/ticker/index.htmlclient/test/live-view.test.jsexamples/README.mdCLAUDE.mdWhat's Not in Client Phase 2
lv-change/lv-submit(Phase 3 — forms, client + server together)off()method for unregistering push handlers (no demonstrated need)paramson connect (needs server-sidemount(socket, params))Beta Was this translation helpful? Give feedback.
All reactions