MCPcopy
hub / github.com/angular/angular / callback

Method callback

packages/core/src/defer/idle_scheduler.ts:104–126  ·  view source on GitHub ↗
(deadline?: IdleDeadline)

Source from the content-addressed store, hash-verified

102
103 const key = getIdleRequestKey(options);
104 const callback = (deadline?: IdleDeadline) => {
105 this.cancelBucket(bucket);
106
107 for (const cb of bucket.queue) {
108 cb();
109 // _tick here is an optimized change detection check and is safe to call here.
110 // We also account for the time it takes to run change detection
111 // for the newly-created view as a part of the same idle callback.
112 this.applicationRef._tick();
113 bucket.queue.delete(cb);
114 this.callbackBucket.delete(cb);
115
116 if (deadline && deadline.timeRemaining() === 0 && !deadline.didTimeout) {
117 break;
118 }
119 }
120
121 if (bucket.queue.size > 0) {
122 this.scheduleBucket(bucket, options);
123 } else {
124 this.buckets.delete(key);
125 }
126 };
127
128 // Ensure that the callback runs in the NgZone since
129 // the `requestIdleCallback` is not currently patched by Zone.js.

Callers

nothing calls this directly

Calls 5

cancelBucketMethod · 0.95
scheduleBucketMethod · 0.95
_tickMethod · 0.80
cbFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected