egil / Htmxor

Supercharges Blazor static server side rendering (SSR) by seamlessly integrating the Htmx.org frontend library.
MIT License
109 stars 12 forks source link

Enable streaming rendering #16

Open egil opened 3 months ago

tanczosm commented 3 months ago

For streaming rendering just be careful because Htmx doesn't support streaming rendering on requests at the moment.

egil commented 3 months ago

For streaming rendering just be careful because Htmx doesn't support streaming rendering on requests at the moment.

What do you mean exactly? I imagine a custom plugin is needed to handle the response during streaming rendering so that it gets patched into the DOM correctly. Didn't you manage to get something like that to work?

tanczosm commented 3 months ago

Ah I forgot we discussed this exact thing. Htmx natively just handles responses only when they have completed, so you end up having to wait out the entire streaming result But yes, I did create an extension to handle that issue. It will need some small updating for htmx 2.0 though since they changed the swapping api methods but the changes are just a few lines. If you get streaming to work then it can work via an extension.

egil commented 3 months ago

Yeah, sounds good. I'm just trying to get the basics working, then adding streaming. can you share a link to your extension so I can have a look when I get the time to look at streaming?

tanczosm commented 3 months ago

Here you go:

https://github.com/JalexSocial/Rizzy/blob/main/src/Rizzy/wwwroot/js/blazor-streaming.js

Note that one issue with this code is it defines the blazor-ssr-end html element internally, which if used with blazor.web.js would require the component to be loaded after blazor.web.js (it checks to see if the blazor-ssr-end html element is already defined) but admittedly I haven't tested this scenario because blazor.web.js also implements a lot of functionality similar to htmx that is only used by Blazor so I've tried to steer clear of any blazor javascript dependencies.

egil commented 3 months ago

Yeah, may current strategy is to completely remove blazer.web.js from the mix.