-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SSE tests and emit new "beforeMessage" event for SSE Extension #2171
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Especially thank you for fixing syntax errors in SSE tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github extension for VS code sent my approve twice, disregard this comment
@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:beforeSwap
andhtmx:afterSwap
events. Similarly, the WS extension emitshtmx:wsBeforeMessage
andhtmx: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
master
for website changes,dev
forsource changes)
approved via an issue
npm run test
) and verified that it succeeded