htmx: Server Sent Event (SSE) Extension

(htmx.org)

32 points | by tosh 3 hours ago ago

5 comments

  • bullen 5 minutes ago

    What is the advantage over just using this:

      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?

  • wild_egg an hour ago

    FWIW, this will be part of the core library in the next version instead of a separate extension.

    https://four.htmx.org/htmx-4/#built-in-streaming-response-su...

  • nasretdinov 3 hours ago

    As a backend engineer I really like where all of this is going. In many many cases you do not need anything beyond what HTMX provides, and it makes the build and testing process so much simpler, and faster too

  • gf000 2 hours ago

    I have given a try to data-star that is pretty similar to htmx, and it already had SSE support. (But I think it is a bit more complete solution to the problem - giving lightweight primitives for client-side interactivity)

    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.