Answer the question
In order to leave comments, you need to log in
How to implement background cyclic requests to the server in Angular?
This is necessary, for example, for a chat, to check whether a message has come from the interlocutor. Through the loop, the application will hang the browser heavily.
Answer the question
In order to leave comments, you need to log in
On idea to you it is necessary to do through setTimeout instead of through a cycle.
But in general, it is more correct to use web sockets for such purposes, since heaps of requests will load the server. And when the data itself comes through websockets, then everything works quickly and does not load the server.
Here are a couple of examples for working with cometserver:
https://comet-server.com/wiki/doku.php/comet:intro...
https://github.com/CppComet/php-chat-example
https:// comet-server.com/wiki/doku.php/comet:chat-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question