MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / $IntervalProvider

Function $IntervalProvider

lib/test/angular/1.8.0/angular.js:14122–14297  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

14120
14121/** @this */
14122function $IntervalProvider() {
14123 this.$get = ['$$intervalFactory', '$window',
14124 function($$intervalFactory, $window) {
14125 var intervals = {};
14126 var setIntervalFn = function(tick, delay, deferred) {
14127 var id = $window.setInterval(tick, delay);
14128 intervals[id] = deferred;
14129 return id;
14130 };
14131 var clearIntervalFn = function(id) {
14132 $window.clearInterval(id);
14133 delete intervals[id];
14134 };
14135
14136 /**
14137 * @ngdoc service
14138 * @name $interval
14139 *
14140 * @description
14141 * AngularJS's wrapper for `window.setInterval`. The `fn` function is executed every `delay`
14142 * milliseconds.
14143 *
14144 * The return value of registering an interval function is a promise. This promise will be
14145 * notified upon each tick of the interval, and will be resolved after `count` iterations, or
14146 * run indefinitely if `count` is not defined. The value of the notification will be the
14147 * number of iterations that have run.
14148 * To cancel an interval, call `$interval.cancel(promise)`.
14149 *
14150 * In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to
14151 * move forward by `millis` milliseconds and trigger any functions scheduled to run in that
14152 * time.
14153 *
14154 * <div class="alert alert-warning">
14155 * **Note**: Intervals created by this service must be explicitly destroyed when you are finished
14156 * with them. In particular they are not automatically destroyed when a controller's scope or a
14157 * directive's element are destroyed.
14158 * You should take this into consideration and make sure to always cancel the interval at the
14159 * appropriate moment. See the example below for more details on how and when to do this.
14160 * </div>
14161 *
14162 * @param {function()} fn A function that should be called repeatedly. If no additional arguments
14163 * are passed (see below), the function is called with the current iteration count.
14164 * @param {number} delay Number of milliseconds between each function call.
14165 * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat
14166 * indefinitely.
14167 * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
14168 * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
14169 * @param {...*=} Pass additional parameters to the executed function.
14170 * @returns {promise} A promise which will be notified on each iteration. It will resolve once all iterations of the interval complete.
14171 *
14172 * @example
14173 * <example module="intervalExample" name="interval-service">
14174 * <file name="index.html">
14175 * <script>
14176 * angular.module('intervalExample', [])
14177 * .controller('ExampleController', ['$scope', '$interval',
14178 * function($scope, $interval) {
14179 * $scope.format = 'M/d/yy h:mm:ss a';

Callers

nothing calls this directly

Calls 2

markQExceptionHandledFunction · 0.70
clearIntervalFnFunction · 0.70

Tested by

no test coverage detected