-
Notifications
You must be signed in to change notification settings - Fork 65
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: Allow SSE extension to use a user-defined EventSource object #143
Comments
Hey, it's not documented (documentation improvement PRs are always welcome btw!), but you should already be able to do it ;
So, you could already override Hope this helps! |
Hi, @Telroshan thank you for this. Although this works, I'd like to make a PR for this as this looks like a hack. I'd like to have something like: function createEventSource() {
return Promise.resolve(new EventSource("/sse-events"));
} <div hx-ext="sse" sse-create="createEventSource" sse-swap="message"> Let me know if this is something that may get accepted. |
Hey, it's indeed not documented, which isn't ideal for sure, but it's not a hack don't worry about that, it was designed in this way so that it can be overridden, which is precisely your intent here. Honestly I don't think adding an extra attribute is very relevant here ;
However, if you need some async logic here to initialize the event source, it's true that for now, the extension doesn't support an async |
If we could make the For now, my requirements are already satisfied using the synchronous |
Sorry, I can't seem to find the source for the documentation. Please feel free to close this issue as I have a limited time and can no longer work on the documentation part. |
Yeah we had to run a trick for this to keep the core extensions' documentation be on the main website, if you look at this repo's No worries about the lack of time! |
#139 Is similar and a fully tested EventSource replacement I use in production. (Unsure if it removes any browser connection limits though.) Just dealing with some chaos with launching my startup. I should be able to tackle this in a few months. |
This will allow more control over the behavior of the SSE connection. For instance, I want to implement the fix for this firefox bug where I need to have access to the
EventSource
object for this to be implemented. This will also fix several issues:Another advantage is to be able to add event listeners outside of
htmx
context.Also, the number of connections is limited to only 6 when not used in
HTTP2
, so it would be beneficial to reused an existing connection across multiple independent elements.The text was updated successfully, but these errors were encountered: