Mechanism for having an endpoint acts like a socket #11980
-
Hi there, I have an endpoint that is very slow and can potentially return a lot of objects. Currently, in my application this is what I'm doing:
For the end-user, this turns into a potentially very slow experience because the page won't load until everything has been loaded. It can take up to 30 seconds sometimes. Ideally what I would like is the following:
This allows the end-user to see things as soon as they have been fetched. This feels like a better user experience, even if there is some slow stuff going on behind the scenes. What I think I need here, is some sort of socket-like mechanism that can pass through objects as they're retrieved. I might be wrong about this though 😂 Would anyone be able to point me in the right direction here? I've taken a look through the documentation and had a Google, but am unable to find exactly what I'm looking for. Thanks! -Dave |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I am not sure you need websockets for this, regular HTTP requests will work as expected. If you have 5 expensive tasks, you can fire 5 requests concurrently and as soon as one of them resolve, you can start rendering the data in the app. |
Beta Was this translation helpful? Give feedback.
-
Hey @rafaelalmeidatk thanks for the response :) I'd began writing a response to the tune of "I don't think that this is the best idea as the thing I'm working on is an exception to where this would be best practice" and then realised that I've overthought this way too much and that you are indeed correct 😂. To work out how many requests need sending and what those requests are/look like is an inexpensive operation, so I could:
Thanks for causing me to rubber duck this and see the error in my ways! -Dave |
Beta Was this translation helpful? Give feedback.
I am not sure you need websockets for this, regular HTTP requests will work as expected. If you have 5 expensive tasks, you can fire 5 requests concurrently and as soon as one of them resolve, you can start rendering the data in the app.