I like responsive application behavior which I may achieve with @PUSH
. The downside of this approach - the issue with web-sockets which stop working for the unknown reason on my iPhone after some unpredictable period of time. The only solution right now I know - is to refresh the application in browser. Maybe this is a flaky network maybe something else.. I don't know right now.
How I use @PUSH
: I load the page with a number of blocks.. let's say portlets. I show ProgressBar
on their placeholders first and then asynchronously load its content with @PUSH. Works perfectly when it works..
In order to avoid the issue with websockets I'm thinking on other approaches, for example:
Is there any way to achieve the same with Vaadin without @PUSH
? I'd like to still show the ProgressBar
first to the user and do the XHR requests, then load portlet content asynchronously. Is it possible to execute such asynchronous logic on the client side in separate calls to the server without pushing from the server side like I do now?
Right now without PUSH everything is delivered to the client in a single UIDL response and even if I try to show the ProgressBar… it will not be shown because it will be sent to the client in a one single UIDL batch with portlet content data where I change the visibility of ProgressBar to false at the very end.
CodePudding user response:
One thing you can do is to use UI polling instead. In that way, the client will send HTTP requests to the server at regular intervals just to check if there are any new changes to fetch. You can enable that using the setPollInterval
method in UI
.
You can add a little bit of own logic to enable polling when some background fetching is started and disabling it again when everything is loaded for that user.
Finally, I also want to point out that the websocket connection is supposed to recover even if the network connection is flaky, so there might be some case that the framework doesn't handle properly in your case. If you have any additional hints about that situation, then please open a ticket at https://github.com/vaadin/flow/issues/new/choose so that we can try to pinpoint and fix it.