MCPcopy Create free account
hub / github.com/angular/angular / callback

Method callback

packages/core/src/defer/idle_scheduler.ts:104–127  ·  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 // Keep idleId set during the drain to prevent re-entrant add() from scheduling redundant callbacks.
106 for (const cb of bucket.queue) {
107 cb();
108 // _tick here is an optimized change detection check and is safe to call here.
109 // We also account for the time it takes to run change detection
110 // for the newly-created view as a part of the same idle callback.
111 this.applicationRef._tick();
112 bucket.queue.delete(cb);
113 this.callbackBucket.delete(cb);
114
115 if (deadline && deadline.timeRemaining() === 0 && !deadline.didTimeout) {
116 break;
117 }
118 }
119
120 bucket.idleId = null;
121
122 if (bucket.queue.size > 0) {
123 this.scheduleBucket(bucket, options);
124 } else {
125 this.buckets.delete(key);
126 }
127 };
128
129 // Ensure that the callback runs in the NgZone since
130 // the `requestIdleCallback` is not currently patched by Zone.js.

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected