WASM: add declarative event handling and targeted DOM updates #5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
WASM interactivity currently requires manual
syscall/jsbridging. Each interactive element needs:js.Global().Set()app.jsReset()+ rebuild on every interactionThe
08_water_tank_multiexample shows this works but it's boilerplate-heavy and splits interaction logic across Go and JS files.This came up building gogal WASM demos — the HTMX example (server-side legend toggling) has no clean WASM equivalent because there's no event mechanism in the model.
What HTMX provides (for comparison)
hx-trigger="click"on any elementhx-target="#chart"replaces only part of the pagehx-trigger="every 2s"for periodic refresh of a regionProposed API
A minimal extension that stays true to lofigui's philosophy (no JS frameworks, Go-first):
1. Go-side action registration
2. Targeted DOM updates
3. JS side (built into lofigui's WASM runtime, not user-written)
goRender(), scan fordata-actionattributes and attach click handlersgoAction(name, param)(new exported function)goActiondispatches to registered Go callbackgoRenderTarget(name)returns just one region's HTML for partial updateComplexity budget
This should be ~100 lines in lofigui (wasm.go + a target registry). The user writes zero JS for basic interactions. The existing
app.jspattern continues to work for custom cases.Alternatives considered
syscall/js: works but duplicates boilerplate across every interactive exampleUse cases from gogal
Migrated from Codeberg: originally #5, opened 2026-04-08.