Skip to content

Commit bf3bbb2

Browse files
author
Michael Wunderlich
committed
cancel intervals on navigation
1 parent 2cab818 commit bf3bbb2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

public/app/gameController.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,8 @@ function Game($q, $scope, $http, $interval, $routeParams, SessionService, UserSe
7272

7373
});
7474
}
75-
75+
$scope.$on('$destroy',function(){
76+
if($scope.interval)
77+
$interval.cancel($scope.interval);
78+
});
7679
}

public/app/sessionController.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function Session($scope, $http, $location, $interval, $routeParams, SessionServi
4141
$scope.interval = $interval(function(){
4242
$scope.loadSession();
4343
}, 5000);
44-
4544
$scope.createGame = function (gamename, gamerules) {
4645
var sessionid = $routeParams.sessionid;
4746

@@ -95,4 +94,8 @@ function Session($scope, $http, $location, $interval, $routeParams, SessionServi
9594
$location.path('/');
9695
});
9796
};
97+
$scope.$on('$destroy',function(){
98+
if($scope.interval)
99+
$interval.cancel($scope.interval);
100+
});
98101
}

0 commit comments

Comments
 (0)