angular-timer icon indicating copy to clipboard operation
angular-timer copied to clipboard

Finish-callback being executed twice - every time

Open Wombatpm opened this issue 9 years ago • 3 comments

I'm using angular-timer to count down for an auction event that happens every 20 minutes or so. When the end time is reached I contact the service via a REST api and get the next auction time. Every time the auction ends I get 2 calls to the service.

<timer end-time="vm.auction" interval="1000" finish-callback="vm.auctionended()"><b>{{hhours}}</b><span timelabel>H</span><b>{{mminutes}}</b><span timelabel>M</span><b>{{sseconds}}</b><span timelabel>S</span></timer>

Controller

    vm.auctionended = function() {
      debuglog('Auction Ended - get next value');
      getNextAuction();
    }

    function getNextAuction() {
      nextAuction().then(function(resp) {
        vm.auction = resp.getTime();
        store.set('auction', vm.auction);
        console.log($scope.$id);
        console.trace();
        $scope.$broadcast('timer-start');
      });

My Console log looks like this :+1:


timer-controller.js:15 timer-controller
timer-controller.js:67 Stored Auction time is still valid
timer-controller.js:67 Auction Ended - get next value
timer-controller.js:67 Next Auction:
Wed Apr 27 2016 17:19:59 GMT-0500 (Central Daylight Time)
timer-controller.js:48 26
timer-controller.js:49 console.trace()(anonymous function) @ timer-controller.js:49processQueue @ ionic.bundle.js:27879(anonymous function) @ ionic.bundle.js:27895Scope.$eval @ ionic.bundle.js:29158Scope.$digest @ ionic.bundle.js:28969Scope.$apply @ ionic.bundle.js:29263done @ ionic.bundle.js:23676completeRequest @ ionic.bundle.js:23848requestLoaded @ ionic.bundle.js:23789
timer-controller.js:67 Auction Ended - get next value
timer-controller.js:67 Next Auction:
Wed Apr 27 2016 17:19:59 GMT-0500 (Central Daylight Time)
timer-controller.js:48 26
timer-controller.js:49 console.trace()(anonymous function) @ timer-controller.js:49processQueue @ ionic.bundle.js:27879(anonymous function) @ ionic.bundle.js:27895Scope.$eval @ ionic.bundle.js:29158Scope.$digest @ ionic.bundle.js:28969Scope.$apply @ ionic.bundle.js:29263done @ ionic.bundle.js:23676completeRequest @ ionic.bundle.js:23848requestLoaded @ ionic.bundle.js:23789
timer-controller.js:67 Auction Ended - get next value
timer-controller.js:67 Next Auction:
Wed Apr 27 2016 17:39:59 GMT-0500 (Central Daylight Time)
timer-controller.js:48 26
timer-controller.js:49 console.trace()(anonymous function) @ timer-controller.js:49processQueue @ ionic.bundle.js:27879(anonymous function) @ ionic.bundle.js:27895Scope.$eval @ ionic.bundle.js:29158Scope.$digest @ ionic.bundle.js:28969Scope.$apply @ ionic.bundle.js:29263done @ ionic.bundle.js:23676completeRequest @ ionic.bundle.js:23848requestLoaded @ ionic.bundle.js:23789
timer-controller.js:67 Auction Ended - get next value
timer-controller.js:67 Next Auction:
Wed Apr 27 2016 17:39:59 GMT-0500 (Central Daylight Time)
timer-controller.js:48 26
timer-controller.js:49 console.trace()(anonymous function) @ timer-controller.js:49processQueue @ ionic.bundle.js:27879(anonymous function) @ ionic.bundle.js:27895Scope.$eval @ ionic.bundle.js:29158Scope.$digest @ ionic.bundle.js:28969Scope.$apply @ ionic.bundle.js:29263done @ ionic.bundle.js:23676completeRequest @ ionic.bundle.js:23848requestLoaded @ ionic.bundle.js:23789
timer-controller.js:67 Auction Ended - get next value
timer-controller.js:67 Next Auction:
Wed Apr 27 2016 17:59:59 GMT-0500 (Central Daylight Time)
timer-controller.js:48 26
timer-controller.js:49 console.trace()(anonymous function) @ timer-controller.js:49processQueue @ ionic.bundle.js:27879(anonymous function) @ ionic.bundle.js:27895Scope.$eval @ ionic.bundle.js:29158Scope.$digest @ ionic.bundle.js:28969Scope.$apply @ ionic.bundle.js:29263done @ ionic.bundle.js:23676completeRequest @ ionic.bundle.js:23848requestLoaded @ ionic.bundle.js:23789
timer-controller.js:67 Auction Ended - get next value
timer-controller.js:67 Next Auction:
Wed Apr 27 2016 17:59:59 GMT-0500 (Central Daylight Time)
timer-controller.js:48 26
timer-controller.js:49 console.trace()

Wombatpm avatar Apr 27 '16 22:04 Wombatpm

i think i got the same issue: https://github.com/siddii/angular-timer/issues/244

maltegrosse avatar Apr 28 '16 06:04 maltegrosse

@maltegrosse I saw your issue, but I don't have any incrementing variables, but I do have everything wrapped in a promise. My stack trace is the same for both calls.

timer-controller.js:49 console.trace()(anonymous function) 
@ timer-controller.js:49processQueue 
@ ionic.bundle.js:27879(anonymous function) 
@ ionic.bundle.js:27895Scope.$eval 
@ ionic.bundle.js:29158Scope.$digest 
@ ionic.bundle.js:28969Scope.$apply 
@ ionic.bundle.js:29263done 
@ ionic.bundle.js:23676completeRequest 
@ ionic.bundle.js:23848requestLoaded 
@ ionic.bundle.js:23789

Wombatpm avatar Apr 28 '16 06:04 Wombatpm

When is the fix for this issue being rolled out?

Sayaliingle avatar Jul 28 '16 16:07 Sayaliingle