Fix SSE tests and emit new "beforeMessage" event for SSE Extension#2171
Fix SSE tests and emit new "beforeMessage" event for SSE Extension#21711cg merged 5 commits intobigskysoftware:devfrom
Conversation
|
It may also make sense to rename the |
|
Hi, Given that the naming is at least consistent with the ws version it seems like the best choice for the name of the event if thats what is decided to be the best solution. That said, I do think that the future of the sse extension would probably be to use htmx's built in swap function rather than the bespoke one that is currently being used, and therefore emit both before and after swap events consistent with the existing htmx behavior. (see #844 (comment) for context) If having I would also suggest that you add a regression test to the testing suite no matter what the solution is. |
|
@Renerick, thanks so much for the first review and your comments. I've updated the code to add cancellation support and added tests to verify that the events are being emitted correctly. Can you take another look? In the process, I also fixed our test suites for the SSE extension and |
Renerick
left a comment
There was a problem hiding this comment.
LGTM
Especially thank you for fixing syntax errors in SSE tests
|
@Renerick are you able to run CI so we can get this merged? |
Description
I'm building a toy chat app with HTMX + the SSE extension. I have some custom JS that I want to run before and after new SSE messages are swapped in from the server.
For a regular request with HTMX, I could add listeners to the
htmx:beforeSwapandhtmx:afterSwapevents. Similarly, the WS extension emitshtmx:wsBeforeMessageandhtmx:wsAfterMessage, but there is no corresponding ability to listen to "before swap" messages with the SSE extension.This PR introduces a new event,
htmx:sseBeforeMessage, that is emitted before the SSE extension swaps in content from the server. Open to feedback on naming convention!Testing
I tested this change manually by applying this patch to my local copy of the SSE extension.
Checklist
masterfor website changes,devforsource changes)
approved via an issue
npm run test) and verified that it succeeded