-
Notifications
You must be signed in to change notification settings - Fork 934
Description
Hello,
I'm using angular-timer in my project to create a countdown, and I noticed that if I bind a finish-callback to the end of the countdown that changes one of my scope variables, it doesn't update automatically that variable.
I made some checks and I figured out that the problem is that the library does use setTimeout in place of $timeout. I see also that this choice has been made because $timeout breaks e2e testing. Whereas I don't think not using $timeout in production is the best solution, I understand your choice but, at least, you need to guarantee the same functionality as if $timeout is used.
I see that the code that creates timeout is
//We are not using $timeout for a reason. Please read here - https://github.com/siddii/angular-timer/pull/5
$scope.timeoutId = setTimeout(function () {
tick();
$scope.$digest();
}, $scope.interval - adjustment);
But this way when the timeout ticks, it does not re-evaluate the scope, so it does not update watchers.
I suggest to change
$scope.$digest(); in $scope.$apply(); (which calls $scope.$digest() itself) to resolve the issue.
What do you think @siddii ?
Simone