I am using the method based on this answer: Server polling with AngularJS
But how can I set this update when I have multiple polling methods?
Here is a snippet of my service:
function pollingService($resource) {
return {
methodA: $resource(window.rootUrl + 'api/methodA', { para: '@para1' }, {
query: { method: 'GET', params: {}, isArray: false }
}),
methodB: $resource(window.rootUrl + 'api/methodB', {}, {
query: { method: 'GET', params: {}, isArray: false }
})
}
};
So how can I set up the tick method to poll theese 2 methods and only create 1 polling loop?
(function tick() {
$scope.method1 = pollingService.methodA.query(function () {
$timeout(tick, $scope.refreshRate);
});
$scope.method2 = pollingService.methodB.query(function () {
$timeout(tick, $scope.refreshRate);
});
})();