Skip to content

SSE onopen event #1325

@hirschenberger

Description

@hirschenberger

Hey,

I have a webapp that needs some kind of connection-tracking (online-offline). I use the SSE ext. for triggering updates in my frontend.

On connection loss, I open a modal like this:

  htmx.on("htmx:sseError", function(evt){
                        console.log("SSE disconnect");
                        htmx.addClass(htmx.find("#disconnect-modal"), "is-active");

It would be great to also have a lifecycle event for reconnection or connection at all. I tried to access the eventSource object from the internal data to add a callback to onopen but it does not work.

How about adding an event htmx:sseOpen to the sse extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions