https://four.htmx.org/htmx-4/#built-in-streaming-response-su...
what is going to change is that htmx will ship with the "core" extensions (ws, sse, optimistic responses, etc.) as a single release, so they can all be composed easily together and are tested together
we'll see, still in alpha
I think it's (referring to both) a pretty nice framework, though it does require a bit of mental "undoing" if you have worked a lot with SPAs.
It's also neat how they use SSE for short-lived streams. Need a response to delete + add something? That's just two SSE events and then the stream closes. It's not a special case, it's a first-class mechanism.
Very happy with Datastar so far.
There are cases where you need more than htmx / datastar, but i like the explicit calling out of when these boundaries occur (e.g. you've exceeded what "islands" can give you), and i like the gravitational pull to lower levels.
You can't do virtual scroll over a billion checkboxes in HTMX (I've yet to see anyone manage in react for that matter either), yet you can do it easily in Datastar. [1]
The only reason I wheel it out is when people say you can't do X (often meaning react like things) with hypermedia.
Honestly, you could probably do it in HTMX if you are prepared to only use out of bounds swaps, morph and SSE. But, that approach has always felt second class, unfinished and against the grain. So stuff like that isn't done.
Always made me sad that you wrote idiomorph (thanks for sharing it with the world) but didn't make it part of HTMX. I guess HTMX 4 will change that?
var source = new EventSource('pull?name=one');
source.onmessage = function (event) {
document.getElementById('events').innerHTML += event.data;
};
http://talk.rupy.se/event.html> If you need bi-directional communication, then you should consider using WebSockets instead.
Or you just do a HTTP request?
https://htmx.org/attributes/hx-swap/ https://htmx.org/attributes/hx-swap-oob/ https://htmx.org/attributes/hx-target/
check out fixi for our ultra-minimalist take on the idea:
https://github.com/bigskysoftware/fixi
Or, for extreme minimalisim, htmz, which repurposes iframes for a similar idea:
Yes one can add a callback function to parse the data as JSON, do error handling etc. and then swap the text/HTML, but having that built in to a hx-foo attribute would be a lot easier.
Yes you have to add this yourself, but you only need to add one js function once and be done with it.
I've used the callback pattern for custom error handling for all hx responses.
What use case do you have in mind?