Rendered at 14:09:30 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
yawaramin 18 hours ago [-]
> Fiddling with out-of-band swaps to solve this feels error prone and overly hard to maintain.
This is almost always because of using a string-based templating system. If you use a language-embedded HTML generation library, it represents HTML fragments as first-class values in your language, and you can compose them together in flexible ways. This makes out-of-band swaps very simple.
wmanley 16 hours ago [-]
You mean by having a function per fragment? I don’t think this solves the hard to maintain bit - which is “which fragments should I regenerate/send”, and how do I keep that list up to date as my app evolves.
FWIW I have a potential solution: to show live data in my app I use an SSE stream of OOB swaps. On every relevant change to the database I regenerate the HTML and compare it to the previously generated html to create OOB swaps (including hx-preserve). I send that down so the browser can update.
The same approach could be used for normal POSTs. On a POST generate the HTML before and after modifying the database and diff them to generate OOB swaps.
JSR_FDED 12 hours ago [-]
Datastar makes this even simpler. No need to think about OOB swaps. Just regenerate the page and Datastar streams it over SSE and surgically updates the DOM. They call this “fat morph”. You can be more precise about individual updates but it’s hardly ever necessary - it’s basically instantaneous.
Given how much you’ve already developed it would take you no time to pick it up but of course it’s nice to control your own destiny with your own code.
There’s one additional thing you get with Datastar and that’s a very easy Signals implementation on the browser side. For lightweight interactivity you don’t need a server trip. And when you do POST something to the server the values of the signals are automatically included so your backend code knows the front end UI state (and can modify it).
eliasdejong 15 hours ago [-]
> FWIW I have a potential solution: to show live data in my app I use an SSE stream of OOB swaps.
You might be interested in Datastar [1], which is like htmx but centered around Server-Sent Events. You don't have to do diffing yourself in application code because it's already handled by the framework under the hood through the "idiomorph" DOM morphing algorithm.
Sure, that's basically what Phoenix LiveView does. But I would submit that you don't actually need that level of complexity with a bit of judicious UI/UX design, where as the app grows in scale, the number of oob swaps to keep track of doesn't grow as much.
There are many ways to skin the cat.
13 hours ago [-]
dhamidi 17 hours ago [-]
HTMX is great, Hypermedia and HATEOAS are great, HTML-string-templates are not great.
For some reason they are still popular.
A fun experiment is to use a JS runtime with React but render the component tree on the server onto a Writeable stream.
Very easy to understand, no useEffect footguns, great composability.
arthurcolle 20 hours ago [-]
Video doesn't seem to be rendering, has 0:00 and 0:00 as start and end times
QuantumNomad_ 19 hours ago [-]
Video codec is avc1. I think in Safari on iOS this codec is not available on iPhones older than iPhone 15 Pro.
arthurcolle 15 hours ago [-]
I have an iPhone 15 Pro Max. Damn you Tim Apple
QuantumNomad_ 8 hours ago [-]
But then that codec should work.
Maybe there is something else about the video that iOS doesn’t like also?
This is almost always because of using a string-based templating system. If you use a language-embedded HTML generation library, it represents HTML fragments as first-class values in your language, and you can compose them together in flexible ways. This makes out-of-band swaps very simple.
FWIW I have a potential solution: to show live data in my app I use an SSE stream of OOB swaps. On every relevant change to the database I regenerate the HTML and compare it to the previously generated html to create OOB swaps (including hx-preserve). I send that down so the browser can update.
The same approach could be used for normal POSTs. On a POST generate the HTML before and after modifying the database and diff them to generate OOB swaps.
Given how much you’ve already developed it would take you no time to pick it up but of course it’s nice to control your own destiny with your own code.
There’s one additional thing you get with Datastar and that’s a very easy Signals implementation on the browser side. For lightweight interactivity you don’t need a server trip. And when you do POST something to the server the values of the signals are automatically included so your backend code knows the front end UI state (and can modify it).
You might be interested in Datastar [1], which is like htmx but centered around Server-Sent Events. You don't have to do diffing yourself in application code because it's already handled by the framework under the hood through the "idiomorph" DOM morphing algorithm.
[1] https://data-star.dev/
There are many ways to skin the cat.
For some reason they are still popular.
A fun experiment is to use a JS runtime with React but render the component tree on the server onto a Writeable stream.
Very easy to understand, no useEffect footguns, great composability.
Maybe there is something else about the video that iOS doesn’t like also?