The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/core/services/timer.js

34 lines
688 B

define([
'angular',
'lodash',
'../core_module',
],
function (angular, _, coreModule) {
'use strict';
10 years ago
coreModule.default.service('timer', function($timeout) {
// This service really just tracks a list of $timeout promises to give us a
// method for cancelling them all when we need to
var timers = [];
this.register = function(promise) {
timers.push(promise);
return promise;
};
this.cancel = function(promise) {
timers = _.without(timers,promise);
$timeout.cancel(promise);
};
this.cancelAll = function() {
_.each(timers, function(t) {
$timeout.cancel(t);
});
timers = [];
};
});
});