Replies: 12 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. |
Beta Was this translation helpful? Give feedback.
-
I like injecting htmx (or a wrapper around its internals, maybe an extension API object?) into the extension. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
I'm also adding a new event |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
One possible approach is to let extensions provide their own |
Beta Was this translation helpful? Give feedback.
-
Adding |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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:
Beta Was this translation helpful? Give feedback.
All reactions