bigskysoftware / htmx-extensions

102 stars 30 forks source link

`hx-trigger="sse:<eventName>"` triggering twice in sse@2.1.0 #16

Closed gnituy18 closed 2 weeks ago

gnituy18 commented 3 months ago

The endpoint /component/weather-form/ is triggered twice when receiving the end event.

I am currently using htmx@2.0.0-beta3 and sse@2.1.0

<div hx-ext="sse" sse-close="end" sse-connect="/weather/">
  <div sse-swap="message"></div>
  <div hx-trigger="sse:end" hx-get="/component/weather-form/" hx-swap="afterbegin" hx-target="#form"></div>
</div>

After further investigation, I found that the onEvent function in the extension is triggered both by elements having sse-connect and hx-trigger="sse:*". Consequently, registerSSE is being triggered twice.

Telroshan commented 2 weeks ago

Closing as it was resolvd in #18