MCPcopy Index your code
hub / github.com/angular/angular / onHasTask

Method onHasTask

packages/zone.js/lib/zone-spec/async-test.ts:199–223  ·  view source on GitHub ↗
(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState)

Source from the content-addressed store, hash-verified

197 }
198
199 onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) {
200 delegate.hasTask(target, hasTaskState);
201 // We should only trigger finishCallback when the target zone is the AsyncTestZone
202 // Consider the following cases.
203 //
204 // const childZone = asyncTestZone.fork({
205 // name: 'child',
206 // onHasTask: ...
207 // });
208 //
209 // So we have nested zones declared the onHasTask hook, in this case,
210 // the onHasTask will be triggered twice, and cause the finishCallbackIfDone()
211 // is also be invoked twice. So we need to only trigger the finishCallbackIfDone()
212 // when the current zone is the same as the target zone.
213 if (current !== target) {
214 return;
215 }
216 if (hasTaskState.change == 'microTask') {
217 this._pendingMicroTasks = hasTaskState.microTask;
218 this._finishCallbackIfDone();
219 } else if (hasTaskState.change == 'macroTask') {
220 this._pendingMacroTasks = hasTaskState.macroTask;
221 this._finishCallbackIfDone();
222 }
223 }
224}
225
226export function patchAsyncTest(Zone: ZoneType): void {

Callers

nothing calls this directly

Calls 2

_finishCallbackIfDoneMethod · 0.95
hasTaskMethod · 0.65

Tested by

no test coverage detected