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

Method callback

packages/core/src/defer/idle_scheduler.ts:104–130  ·  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 try {
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 } finally {
114 bucket.queue.delete(cb);
115 this.callbackBucket.delete(cb);
116
117 if (deadline && deadline.timeRemaining() === 0 && !deadline.didTimeout) {
118 break;
119 }
120 }
121 }
122
123 bucket.idleId = null;
124
125 if (bucket.queue.size > 0) {
126 this.scheduleBucket(bucket, options);
127 } else if (this.buckets.get(key) === bucket) {
128 this.buckets.delete(key);
129 }
130 };
131
132 // Ensure that the callback runs in the NgZone since
133 // the `requestIdleCallback` is not currently patched by Zone.js.

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected