I choked reading this imagining people thinking they're doing something simple (as in not complex) by introducing websockets so they can keep state in their Go backend and sync it with their front-end, ya know, to keep track of the # of TODOs checked.
Edit: SSE*
If you mean SSE, then yes that would work just as well (unless you need the bidirectionality for the client to modify some aspect of the connection after the page has loaded). There is an htmx-sse extension too.
I'm not sure how XHR alone would let you automatically get backend state changes reflected to the frontend. You can poll one or more endpoint, but that's more complicated to get right and less efficient.
Yes, that's basically the idea.
Long polling.
Check out (history of) "Comet": https://en.wikipedia.org/wiki/Comet_(programming)#Implementa...
Also writing a client ontop of an existing HTML client is very very easy so even when not on web it's east to implement...
I think you may mean easy. It may be _easy_, but it's not simple. There are so many more moving pieces, failure modes, operational issues now to consider. Websocket connections aren't free.
As someone else mentioned, SSE is a somewhat simpler protocol that achieves the same purpose. Same idea though.
I hate it when a UI tells me I did an action when really there's an asynchronous background task happening that may fail
https://htmx.org/essays/a-real-world-react-to-htmx-port/
htmx can work well for a reasonably large class of web applications. not all, and certainly not all UI patterns, but w/a bit of a mind shift to the hypermedia approach & a bit of accepting some limitations thereof you can simplify a lot of things pretty significantly.
if you try to shoehorn it in to the SPA mindset, triggering server requests on every interaction, yeah, it's not gonna be great