From 4b5929d577b33edc73e3fd50d0408c9e2fb83b4d Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Wed, 25 Oct 2017 12:32:19 +0200 Subject: [PATCH] converted timer.js to timer.ts (#9656) --- public/app/core/services/timer.js | 33 ------------------------------- public/app/core/services/timer.ts | 32 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 33 deletions(-) delete mode 100644 public/app/core/services/timer.js create mode 100644 public/app/core/services/timer.ts diff --git a/public/app/core/services/timer.js b/public/app/core/services/timer.js deleted file mode 100644 index 67ad02367c0..00000000000 --- a/public/app/core/services/timer.js +++ /dev/null @@ -1,33 +0,0 @@ -define([ - 'angular', - 'lodash', - '../core_module', -], -function (angular, _, coreModule) { - 'use strict'; - - 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 = []; - }; - }); - -}); diff --git a/public/app/core/services/timer.ts b/public/app/core/services/timer.ts new file mode 100644 index 00000000000..c7f7aeb961d --- /dev/null +++ b/public/app/core/services/timer.ts @@ -0,0 +1,32 @@ +import _ from 'lodash'; +import coreModule from 'app/core/core_module'; + +export class Timer { + timers = []; + + /** @ngInject */ + constructor(private $timeout) { + } + + register(promise) { + this.timers.push(promise); + return promise; + } + + cancel(promise) { + console.log(promise); + this.timers = _.without(this.timers, promise); + this.$timeout.cancel(promise); + } + + cancelAll() { + _.each(this.timers, function (t) { + this.$timeout.cancel(t); + }); + this.timers = []; + } +} + +coreModule.service('timer', Timer); +// This service really just tracks a list of $timeout promises to give us a +// method for cancelling them all when we need to