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

Function forkInnerZoneWithAngularBehavior

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

Source from the content-addressed store, hash-verified

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

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