Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

Add SSE support for output actions so they can be Async

Open Badgerati opened this issue 2 years ago • 2 comments

Following #439.

Currently when scriptblocks are invoked from the frontend, they invoked in a request-response pattern; this results in actions only happening one the entire request pipeline has finished. This is completely non-ideal if the request takes a while to run and you want to async update a progress bar - or other elements.

The plan for this is to add in WebSocket support, which will enable output actions to occur async to the request - allowing you to now update elements mid-request.

If possible I want to keep the current request-response pattern as the default, and have the WebSocket model enabled via a switch on Use-PodeWebTemplates - as certain hosting providers people are using won't work with WebSockets as the default.

Badgerati avatar Mar 23 '23 22:03 Badgerati

Change in plan with this one, I've opted to use SSE instead of WebSockets. This means for v1.0 I can enable async processing as the default since SSE works over standard HTTP.

WebSockets also requires a bit of refactoring to wok (ie: auth), so once that done I can add WebSockets as another communication alternative.

Badgerati avatar Mar 11 '24 23:03 Badgerati

I've also added a Reset-PodeWebProgress, which is simply a shorthand for resetting a progress bar back to 0.

There's also a new -AsReference on Out-PodeWebElement, which allows you to create a reusable reference of an element, so it can be cached once and then reused again, and again, and ag... yeah. useful for tables with icons for example, instead of returning the same raw icon definition X times, you can do it once and then return a reference to it X times instead - just decreases data transfer, but likely useful for other use cases!

Badgerati avatar Mar 11 '24 23:03 Badgerati