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

Function delayChangeDetectionForEvents

packages/core/src/zone/ng_zone.ts:384–421  ·  view source on GitHub ↗
(zone: NgZonePrivate)

Source from the content-addressed store, hash-verified

382}
383
384function delayChangeDetectionForEvents(zone: NgZonePrivate) {
385 /**
386 * We also need to check _nesting here
387 * Consider the following case with shouldCoalesceRunChangeDetection = true
388 *
389 * ngZone.run(() => {});
390 * ngZone.run(() => {});
391 *
392 * We want the two `ngZone.run()` only trigger one change detection
393 * when shouldCoalesceRunChangeDetection is true.
394 * And because in this case, change detection run in async way(requestAnimationFrame),
395 * so we also need to check the _nesting here to prevent multiple
396 * change detections.
397 */
398 if (zone.isCheckStableRunning || zone.callbackScheduled) {
399 return;
400 }
401 zone.callbackScheduled = true;
402 function scheduleCheckStable() {
403 scheduleCallbackWithRafRace(() => {
404 zone.callbackScheduled = false;
405 updateMicroTaskStatus(zone);
406 zone.isCheckStableRunning = true;
407 checkStable(zone);
408 zone.isCheckStableRunning = false;
409 });
410 }
411 if (zone.scheduleInRootZone) {
412 Zone.root.run(() => {
413 scheduleCheckStable();
414 });
415 } else {
416 zone._outer.run(() => {
417 scheduleCheckStable();
418 });
419 }
420 updateMicroTaskStatus(zone);
421}
422
423function forkInnerZoneWithAngularBehavior(zone: NgZonePrivate) {
424 const delayChangeDetectionForEventsDelegate = () => {

Callers 1

Calls 3

scheduleCheckStableFunction · 0.85
updateMicroTaskStatusFunction · 0.85
runMethod · 0.65

Tested by

no test coverage detected