|
|
|
|
|
by wmanley
121 days 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. |
|
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).