A
A
Andrey Prozorov2017-08-21 19:08:22
Angular
Andrey Prozorov, 2017-08-21 19:08:22

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

1 answer(s)
V
Viktor, 2017-08-22
@Levhav

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 question

Ask a Question

731 491 924 answers to any question