MCPcopy
hub / github.com/angular/angular / forkInnerZoneWithAngularBehavior

Function forkInnerZoneWithAngularBehavior

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

Source from the content-addressed store, hash-verified

424}
425
426function forkInnerZoneWithAngularBehavior(zone: NgZonePrivate) {
427 const delayChangeDetectionForEventsDelegate = () => {
428 delayChangeDetectionForEvents(zone);
429 };
430 const instanceId = ngZoneInstanceId++;
431 zone._inner = zone._inner.fork({
432 name: 'angular',
433 properties: <any>{
434 [isAngularZoneProperty]: true,
435 [angularZoneInstanceIdProperty]: instanceId,
436 [angularZoneInstanceIdProperty + instanceId]: true,
437 },
438 onInvokeTask: (
439 delegate: ZoneDelegate,
440 current: Zone,
441 target: Zone,
442 task: Task,
443 applyThis: any,
444 applyArgs: any,
445 ): any => {
446 // Prevent triggering change detection when the flag is detected.
447 if (shouldBeIgnoredByZone(applyArgs)) {
448 return delegate.invokeTask(target, task, applyThis, applyArgs);
449 }
450
451 try {
452 onEnter(zone);
453 return delegate.invokeTask(target, task, applyThis, applyArgs);
454 } finally {
455 if (
456 (zone.shouldCoalesceEventChangeDetection && task.type === 'eventTask') ||
457 zone.shouldCoalesceRunChangeDetection
458 ) {
459 delayChangeDetectionForEventsDelegate();
460 }
461 onLeave(zone);
462 }
463 },
464
465 onInvoke: (
466 delegate: ZoneDelegate,
467 current: Zone,
468 target: Zone,
469 callback: Function,
470 applyThis: any,
471 applyArgs?: any[],
472 source?: string,
473 ): any => {
474 try {
475 onEnter(zone);
476 return delegate.invoke(target, callback, applyThis, applyArgs, source);
477 } finally {
478 if (
479 zone.shouldCoalesceRunChangeDetection &&
480 // Do not delay change detection when the task is the scheduler's tick.
481 // We need to synchronously trigger the stability logic so that the
482 // zone-based scheduler can prevent a duplicate ApplicationRef.tick
483 // by first checking if the scheduler tick is running. This does seem a bit roundabout,

Callers 1

constructorMethod · 0.85

Calls 14

shouldBeIgnoredByZoneFunction · 0.85
onEnterFunction · 0.85
onLeaveFunction · 0.85
isSchedulerTickFunction · 0.85
updateMicroTaskStatusFunction · 0.85
checkStableFunction · 0.85
forkMethod · 0.65
invokeTaskMethod · 0.65
invokeMethod · 0.65
hasTaskMethod · 0.65
handleErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…