@this
()
| 14055 | |
| 14056 | /** @this */ |
| 14057 | function $IntervalProvider() { |
| 14058 | this.$get = ['$$intervalFactory', '$window', |
| 14059 | function($$intervalFactory, $window) { |
| 14060 | var intervals = {}; |
| 14061 | var setIntervalFn = function(tick, delay, deferred) { |
| 14062 | var id = $window.setInterval(tick, delay); |
| 14063 | intervals[id] = deferred; |
| 14064 | return id; |
| 14065 | }; |
| 14066 | var clearIntervalFn = function(id) { |
| 14067 | $window.clearInterval(id); |
| 14068 | delete intervals[id]; |
| 14069 | }; |
| 14070 | |
| 14071 | /** |
| 14072 | * @ngdoc service |
| 14073 | * @name $interval |
| 14074 | * |
| 14075 | * @description |
| 14076 | * AngularJS's wrapper for `window.setInterval`. The `fn` function is executed every `delay` |
| 14077 | * milliseconds. |
| 14078 | * |
| 14079 | * The return value of registering an interval function is a promise. This promise will be |
| 14080 | * notified upon each tick of the interval, and will be resolved after `count` iterations, or |
| 14081 | * run indefinitely if `count` is not defined. The value of the notification will be the |
| 14082 | * number of iterations that have run. |
| 14083 | * To cancel an interval, call `$interval.cancel(promise)`. |
| 14084 | * |
| 14085 | * In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to |
| 14086 | * move forward by `millis` milliseconds and trigger any functions scheduled to run in that |
| 14087 | * time. |
| 14088 | * |
| 14089 | * <div class="alert alert-warning"> |
| 14090 | * **Note**: Intervals created by this service must be explicitly destroyed when you are finished |
| 14091 | * with them. In particular they are not automatically destroyed when a controller's scope or a |
| 14092 | * directive's element are destroyed. |
| 14093 | * You should take this into consideration and make sure to always cancel the interval at the |
| 14094 | * appropriate moment. See the example below for more details on how and when to do this. |
| 14095 | * </div> |
| 14096 | * |
| 14097 | * @param {function()} fn A function that should be called repeatedly. If no additional arguments |
| 14098 | * are passed (see below), the function is called with the current iteration count. |
| 14099 | * @param {number} delay Number of milliseconds between each function call. |
| 14100 | * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat |
| 14101 | * indefinitely. |
| 14102 | * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise |
| 14103 | * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. |
| 14104 | * @param {...*=} Pass additional parameters to the executed function. |
| 14105 | * @returns {promise} A promise which will be notified on each iteration. It will resolve once all iterations of the interval complete. |
| 14106 | * |
| 14107 | * @example |
| 14108 | * <example module="intervalExample" name="interval-service"> |
| 14109 | * <file name="index.html"> |
| 14110 | * <script> |
| 14111 | * angular.module('intervalExample', []) |
| 14112 | * .controller('ExampleController', ['$scope', '$interval', |
| 14113 | * function($scope, $interval) { |
| 14114 | * $scope.format = 'M/d/yy h:mm:ss a'; |
nothing calls this directly
no test coverage detected