javascript - weird ~infinite loop with $http.get -


i'm doing loop polling, wait events, , i'm having trouble infinite loop. here code:

var app = angular.module('mainapp', []);  app.factory('userevents', function ($http) {      var manageevent = function (event) {          //do work here          //and then, poll:         window.settimeout(poll, 0);     }      var poll = function () {          $http({             method: 'get',             url: '/get-events',         })         .success(function(event, status) {             manageevent(event)         });     }      service = {         poll: poll,     }      return service });  function maincontroller($scope, userevents) {      userevents.poll();  } 

once first event received success method of $http.get executed without request being done, creates loop. @ point magically stops, sending request. it's if function 'poll' using previous $http.get promise, resolved (???)

if set timeout of 200ms in 'manageevent' function, problem doesn't appear, it's not clean solution me.

can explain me what's happening here ?

thanks


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -