-
Notifications
You must be signed in to change notification settings - Fork 56
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
feature request: trigger an SSE start with the hx-trigger #27
Comments
Hello, I'm not sure to understand the issue, sorry if that's off the mark;
It looks like you want to send messages from the client to the server, but please note SSE (Server sent events), is unidirectional, and can only happen from the server to the client.
That sounds weird, SSE events shouldn't trigger unless your server sends those very SSE events in the first place. Would you mind sharing some code to investigate on what's happening here? |
Thank you for your reply! |
Ooh ok I get it, you want to initiate the SSE connection upon user interaction. Is there any reason not to have it initialize the SSE connection automatically on page load though? You could just have it active & idle, until you actually send events from your server. Other than that, there's no current built-in way to do this that I know of, but you could achieve this by
The same ideas apply if you want to instead act on the Basically, |
Thank you for your detailed explanation, I will do something like adding the sse-connect tag on button click. But still, It seems like a lot of effort for something that could be a feature. Of course, it would take time, maybe i'll look at making a code change proposition for this edge case. But thank you for your time. |
I had this same issue and I do not like the solution proposed. sse_connect should be tied to an event to be consistent. |
Hello,
I found in the documentation that it is possible to trigger http callbacks on a specific sse event.
But I do not find anything (and don't seem to be able to get it to work) about using the hx-trigger tag to start sse requests on a user event (like a click to start the server sent events).
forgive me if I missed something in the documentation, but it isn't clear to me why in all my tests, my sse event are just triggered out of the box on page load.
Thank a lot for your help all.
The text was updated successfully, but these errors were encountered: