Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions packages/core/src/defer/idle_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ export class IdleScheduler implements OnDestroy {
const callback = (deadline?: IdleDeadline) => {
// Keep idleId set during the drain to prevent re-entrant add() from scheduling redundant callbacks.
for (const cb of bucket.queue) {
cb();
// _tick here is an optimized change detection check and is safe to call here.
// We also account for the time it takes to run change detection
// for the newly-created view as a part of the same idle callback.
this.applicationRef._tick();
bucket.queue.delete(cb);
this.callbackBucket.delete(cb);

if (deadline && deadline.timeRemaining() === 0 && !deadline.didTimeout) {
break;
try {
cb();
// _tick here is an optimized change detection check and is safe to call here.
// We also account for the time it takes to run change detection
// for the newly-created view as a part of the same idle callback.
this.applicationRef._tick();
} finally {
bucket.queue.delete(cb);
this.callbackBucket.delete(cb);

if (deadline && deadline.timeRemaining() === 0 && !deadline.didTimeout) {
break;
}
}
}

Expand Down