Monday, August 8, 2016

Deferred long-running timer task(s) to improve scrolling smoothness : IONIC

I recently encountered this warring message during the ionic application deployment. In the application console
Deferred long-running timer task(s) to improve scrolling smoothness warring message was keep popping out. After an investigation I found that error was throwing due
$timeout service in angular.


$scope.searchTimer = $timeout(function () { 
    $scope.initiateSearch(true); 
 }, 500); //wait .5 seconds after the user finished typing.

The reason was I was doing a task using a timer. To get rid of this warning message, I had to destroy it after using it. Therefore I used $destroy event to kill the timer.

$scope.$on( 
   "$destroy", 
    function( event ) { 
    $timeout.cancel( timer ); 
 });

1 comment: