Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to update UI without requesting api for data

Let’s say I want to build dynamic chat app.
I want to update users activity status. I can do this with backend requests every x seconds.

But for example Discord can do this without any requests (nothing in network tab in Chrome).

How can I do this? Thanks!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

For this type of requests it’s the server who sends the requests to the client
not the usual HTTP requests where the client request something and the server sends the response so it’s either you use SSE (server-sent-event) unidirectional tunnel or you use a socket which is bidirectional tunnel (socket.io for example) but for this need sse are better so you don’t need to check every x seconds the server notifies the clients subscribed to this tunnel it’s like a notification

check these links:
server-sent-event-1
server-sent-event-2

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading