-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Discussion for SSE extension syntax #618
Comments
SSE questions for @1cg, @dz4k, and the rest of the crew: 1) Publish additional htmx utilities? The existing SSE code (and probably WS code, too) uses a number of internal functions such as
2) Configuration Options? Currently, developers can configure SSE behavior by overriding the
3) Existing hx-trigger events? The existing SSE code can also trigger artificial events that get picked up by I'm sure more issues/questions will come up, and I'll try to post them here so that everyone can weight in. |
I like injecting htmx (or a wrapper around its internals, maybe an extension API object?) into the extension. |
for configuration options, I don't mind if extensions add their own to the standard object, so long as it is documented clearly for events, I like triggering a real event, so long as it is backwards compatible |
I'll update my plans for each of these items accordingly. I like the addition of passing in an "API object" instead of all of htmx. I'll put together a minimal version of this that is needed for the SSE extension. On events, we can just use the existing naming. The only drawback is that they'll be global now, so message names could collide if two SSE sources use the same names. This is probably unlikely, but you know someone is going to do this. |
I'm back into this project for a bit, and can now pass an API object into each extension (branch here). I'm now working to make the list of functions to pass in the API object. Here's my first question: The current SSE code includes the following code to call additional extensions: withExtensions(elt, function(extension){
response = extension.transformResponse(response, null, elt);
}); I think this made sense before, but it feels pretty hanky to be writing an extension that then potentially forks out to other extensions. It seems like we could be enabling bad behavior. Here are two possible solutions/workarounds:
EDIT: @1cg -- For now, I'm running an experiment with option 2. I've added a (temporary?) function to the api object called |
I'm also adding a new event |
IMPORTANT QUESTION ABOUT EXTENSIONS for @1cg and @dz4k I ran into a problem where I think this is because extensions normally enhance or modify the behaviors of the core features like Does this make sense so far? To keep this branch moving, I'm adding I need your help to figure out a way forward that will not break existing extensions but will allow new extensions like SSE and WebSockets to be found and processed correctly. |
One possible approach is to let extensions provide their own |
Adding |
Ok. Thank you, both of you. I'll continue from here and will try to test this with a few other extensions before the PR. This will need several other sets of eyes in it before it makes it into a release. |
GitHub had a meltdown and it broke my previous fork. I've posted all of my progress to a new fork/branch here: https://github.com/benpate/htmx/tree/pr-sse-extension. It's coming along well, and nearly all of my tests are working great. I have to resolve one more issue with hx-settle and then I'll be looking to streamline the code. My current plan:
Currently, the "private api for extensions" object works, but I'm not thrilled with it. It seems like a lot of overhead for a small benefit to rarely used code. Once I have completed WebSockets, I'm thinking it might be better to just ask to put the few methods I need into the public API instead. But, we can cross that bridge when we get there. One last thing: progress is quick, but my time seems limited. When are you aiming to ship version 1.7? |
OK. I've just posted more changes to https://github.com/benpate/htmx/tree/pr-sse-extension
Please take a look and let me know how this looks to you, and how I can make it better. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
We're moving SSE support into an extension (so it was decreed by @1cg). This thread is to collect suggestions/feedback on the syntax that we use in the new code. I'm just getting started now, so please let me know if I'm missing anything, or if there's something we should add. Now is the time :)
I think we should keep it as close to the existing syntax as possible, which should make it easier to migrate to the new code. Here's my first pass:
The text was updated successfully, but these errors were encountered: