Building an Ionic app and have suddenly come across an issue that I am finding really difficult to debug where the browser is 'deferring' long running timer tasks causing my views to execute the code in their controllers only once (even when the controller is explicitly reloaded).
Warning is:
Deferred long-running timer task(s) to improve scrolling smoothness. See crbug.com/574343.
What I'm after:
Thanks in advance.
Update I felt it was important to note that while never receiving errors and only warnings as the cause for my problems, I have since rolled back to a working version.
This working version still has warnings appearing but does not affect the running of my application.
Simply put you can use $q. defer() to create a Promise. A Promise is a function that returns a single value or error in the future. So whenever you have some asynchronous process that should return a value or an error, you can use $q.
$q is integrated with the $rootScope. Scope Scope model observation mechanism in AngularJS, which means faster propagation of resolution or rejection into your models and avoiding unnecessary browser repaints, which would result in flickering UI. Q has many more features than $q, but that comes at a cost of bytes.
We can use $q to defer operations to the future while having a pending promise object at the present, by using $q. defer we create a promise that will either resolve or reject in the future. This method is not equivalent of using the $q constructor, as we use $q.
well in case when you are doing tasks using $timeout , you have got to stop and destroy them else they would create the error you stated
for eg:
var timer = $timeout( function() { console.log( "Timeout executed", Date.now() ); }, 2000 );
if you start a timeout as above then you got to destroy the timer as follows :
// When the DOM element is removed from the page, // AngularJS will trigger the $destroy event on // the scope. This gives us a chance to cancel any // pending timer that we may have. $scope.$on( "$destroy", function( event ) { $timeout.cancel( timer ); } );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With