mirror of
https://github.com/grafana/grafana.git
synced 2025-01-09 15:43:23 -06:00
3a7623753b
* build(webpack): replace babel-loader with esbuild-loader * build(webpack): add esbuild minifier to production builds * Wip * Removed ngInject and replaced with manual inject params * chore: bump esbuild to 0.15.13 * Fixed angular issues * build(frontend): update esbuild to 0.16.16 * chore(webpack): support browserslist for esbuild * build(esbuild): unify versions of esbuild to 0.16.17 and esbuild-loader to 2.21.0 Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
34 lines
798 B
TypeScript
34 lines
798 B
TypeScript
import { ITimeoutService } from 'angular';
|
|
import { without, each } from 'lodash';
|
|
|
|
import coreModule from 'app/angular/core_module';
|
|
|
|
// This service really just tracks a list of $timeout promises to give us a
|
|
// method for canceling them all when we need to
|
|
export class Timer {
|
|
timers: Array<angular.IPromise<any>> = [];
|
|
|
|
static $inject = ['$timeout'];
|
|
|
|
constructor(private $timeout: ITimeoutService) {}
|
|
|
|
register(promise: angular.IPromise<any>) {
|
|
this.timers.push(promise);
|
|
return promise;
|
|
}
|
|
|
|
cancel(promise: angular.IPromise<any>) {
|
|
this.timers = without(this.timers, promise);
|
|
this.$timeout.cancel(promise);
|
|
}
|
|
|
|
cancelAll() {
|
|
each(this.timers, (t) => {
|
|
this.$timeout.cancel(t);
|
|
});
|
|
this.timers = [];
|
|
}
|
|
}
|
|
|
|
coreModule.service('timer', Timer);
|