Skip to content

Commit

Permalink
throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Sep 15, 2013
1 parent 95ba67a commit dad8730
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ angular.module('birdwatch.controllers', ['birdwatch.services', 'charts.barchart'
$(window).resize(function(){
if(TO !== false)
clearTimeout(TO);
TO = setTimeout(resizeWordcloud, 2000);
TO = setTimeout(resizeWordcloud, 2000);
});

var insertionCache = [];
Expand All @@ -72,9 +72,9 @@ angular.module('birdwatch.controllers', ['birdwatch.services', 'charts.barchart'
tweets.registerCallback(function (t) {
insertionCache = insertionCache.concat(t); // every received item is appended to insertionCache.
_.throttle(function() { // throttle because every insertion triggers expensive
$scope.wordCount.insert(insertionCache); // $scope.apply(), insert cache once per second,
$scope.wordCount.insert(insertionCache); // $scope.apply(), insert cache once every 3 seconds,
insertionCache = []; // then empty cache.
}, 1000)();
}, 3000)();

cf.add(t);

Expand Down

0 comments on commit dad8730

Please sign in to comment.