Hi Guilherme,

Using an interval for communication is not a too good idea. While a 10 
seconds interval might be wide enough to not cause problems, I still would 
to prefer a
$timeout option.
something like this:

    function getMyStuff() {
        $http.get('goGetMyStuff')
           .success(function (data) {
              //process the data
              $scope.data = data;
              $timeout(getMyStuff, 10000);
           })
           .error(function (response) {
                // handle the error!
                $timeout(getMyStuff, 10000);
           });
    }

this will achieve mostly the same thing, but there are a few important 
changes.

   1. 
   
   there will be 10 seconds between requests, the time of the request is 
   not part of it!
   2. 
   
   there will always be 1 request. (if for instance the server takes more 
   then 10 secs in your situation a second request will be fired!)
   3. it gives you a better way to handle communication failures 

if you need the response to be quick, using the timeout option of $http 
might be needed.

Regards
Sander
​

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to